Merge branch 'develop'

This commit is contained in:
Pratik Vyas
2015-05-19 12:23:52 +05:30
1388 changed files with 217088 additions and 245106 deletions

View File

@@ -1,9 +1,9 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.country_info import get_country_info
from frappe.geo.country_info import get_country_info
from erpnext.setup.install import add_country_and_currency
def execute():

View File

@@ -1,9 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("manufacturing", "doctype", "bom")
frappe.db.sql("""update tabBOM set total_variable_cost = total_cost""")

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
@@ -8,6 +8,8 @@ from frappe.utils import flt
def execute():
from erpnext.utilities.repost_stock import repost
repost(allow_zero_rate=True, only_actual=True)
frappe.reload_doctype("Account")
warehouse_account = frappe.db.sql("""select name, master_name from tabAccount
where ifnull(account_type, '') = 'Warehouse'""")

View File

@@ -0,0 +1,115 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc("accounts", "doctype", "account")
frappe.reload_doc("setup", "doctype", "company")
frappe.reload_doc("accounts", "doctype", "gl_entry")
frappe.reload_doc("accounts", "doctype", "journal_entry_account")
receivable_payable_accounts = create_receivable_payable_account()
if receivable_payable_accounts:
set_party_in_jv_and_gl_entry(receivable_payable_accounts)
delete_individual_party_account()
remove_customer_supplier_account_report()
def create_receivable_payable_account():
receivable_payable_accounts = frappe._dict()
def _create_account(args):
account_id = frappe.db.get_value("Account",
{"account_name": args["account_name"], "company": args["company"]})
if not account_id:
account = frappe.new_doc("Account")
account.is_group = 0
account.update(args)
account.insert()
account_id = account.name
frappe.db.set_value("Company", args["company"], ("default_receivable_account"
if args["account_type"]=="Receivable" else "default_payable_account"), account_id)
receivable_payable_accounts.setdefault(args["company"], {}).setdefault(args["account_type"], account_id)
for company in frappe.db.sql_list("select name from tabCompany"):
_create_account({
"account_name": "Debtors",
"account_type": "Receivable",
"company": company,
"parent_account": get_parent_account(company, "Customer")
})
_create_account({
"account_name": "Creditors",
"account_type": "Payable",
"company": company,
"parent_account": get_parent_account(company, "Supplier")
})
return receivable_payable_accounts
def get_parent_account(company, master_type):
parent_account = None
if "receivables_group" in frappe.db.get_table_columns("Company"):
parent_account = frappe.db.get_value("Company", company,
"receivables_group" if master_type=="Customer" else "payables_group")
if not parent_account:
parent_account = frappe.db.get_value("Account", {"company": company,
"account_name": "Accounts Receivable" if master_type=="Customer" else "Accounts Payable"})
if not parent_account:
parent_account = frappe.db.sql_list("""select parent_account from tabAccount
where company=%s and ifnull(master_type, '')=%s and ifnull(master_name, '')!='' limit 1""",
(company, master_type))
parent_account = parent_account[0][0] if parent_account else None
return parent_account
def set_party_in_jv_and_gl_entry(receivable_payable_accounts):
accounts = frappe.db.sql("""select name, master_type, master_name, company from `tabAccount`
where ifnull(master_type, '') in ('Customer', 'Supplier') and ifnull(master_name, '') != ''""", as_dict=1)
account_map = frappe._dict()
for d in accounts:
account_map.setdefault(d.name, d)
if not account_map:
return
for dt in ["Journal Entry Account", "GL Entry"]:
records = frappe.db.sql("""select name, account from `tab%s`
where account in (%s) and ifnull(party, '') = '' and docstatus < 2""" %
(dt, ", ".join(['%s']*len(account_map))), tuple(account_map.keys()), as_dict=1)
for i, d in enumerate(records):
account_details = account_map.get(d.account, {})
account_type = "Receivable" if account_details.get("master_type")=="Customer" else "Payable"
new_account = receivable_payable_accounts[account_details.get("company")][account_type]
frappe.db.sql("update `tab{0}` set account=%s, party_type=%s, party=%s where name=%s".format(dt),
(new_account, account_details.get("master_type"), account_details.get("master_name"), d.name))
if i%500 == 0:
frappe.db.commit()
def delete_individual_party_account():
frappe.db.sql("""delete from `tabAccount` acc
where ifnull(acc.master_type, '') in ('Customer', 'Supplier')
and ifnull(acc.master_name, '') != ''
and not exists(select gle.name from `tabGL Entry` gle where gle.account = acc.name)""")
accounts_not_deleted = frappe.db.sql_list("""select name from `tabAccount` acc
where ifnull(acc.master_type, '') in ('Customer', 'Supplier')
and ifnull(acc.master_name, '') != ''
and exists(select gle.name from `tabGL Entry` gle where gle.account = acc.name)""")
if accounts_not_deleted:
print "Accounts not deleted: " + "\n".join(accounts_not_deleted)
def remove_customer_supplier_account_report():
for d in ["Customer Account Head", "Supplier Account Head"]:
frappe.delete_doc("Report", d)

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
@@ -6,11 +6,11 @@ import frappe
def execute():
for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"):
try:
try:
document = frappe.get_doc('BOM', d[0])
if document.docstatus == 1:
document.ignore_validate_update_after_submit = True
document.flags.ignore_validate_update_after_submit = True
document.calculate_cost()
document.save()
except:
pass
pass

View File

@@ -1,19 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('manufacturing', 'doctype', 'bom_operation')
for d in frappe.db.sql("""select bom.name from `tabBOM` bom where bom.docstatus < 2 and
exists(select bom_op.name from `tabBOM Operation` bom_op where
bom.name = bom_op.parent and bom_op.fixed_cycle_cost IS NOT NULL)""", as_dict=1):
try:
bom = frappe.get_doc('BOM', d.name)
bom.ignore_validate_update_after_submit = True
bom.calculate_cost()
bom.save()
frappe.db.commit()
except:
frappe.db.rollback()

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
@@ -6,8 +6,8 @@ import frappe
import json
def execute():
existing_allow_negative_stock = frappe.db.get_default("allow_negative_stock")
frappe.db.set_default("allow_negative_stock", 1)
existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"]
stock_reco_to_be_reposted = []
@@ -28,4 +28,4 @@ def execute():
reco.validate()
reco.on_submit()
frappe.db.set_default("allow_negative_stock", existing_allow_negative_stock)
frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)

View File

@@ -0,0 +1,17 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doc('manufacturing', 'doctype', 'bom_operation')
for d in frappe.db.sql("""select name from `tabBOM` where docstatus < 2""", as_dict=1):
try:
bom = frappe.get_doc('BOM', d.name)
bom.flags.ignore_validate_update_after_submit = True
bom.calculate_cost()
bom.save()
frappe.db.commit()
except:
frappe.db.rollback()

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals