party model patch fix

This commit is contained in:
Nabin Hait 2015-05-05 14:22:10 +05:30
parent 61092c0a88
commit cf22fdbc85

View File

@ -19,17 +19,20 @@ def create_receivable_payable_account():
receivable_payable_accounts = frappe._dict()
def _create_account(args):
if not frappe.db.get_value("Account",
{"account_name": args["account_name"], "company": args["company"]}):
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.name)
if args["account_type"]=="Receivable" else "default_payable_account"), account_id)
receivable_payable_accounts.setdefault(args["company"], {}).setdefault(args["account_type"], account.name)
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({