Party model patch fix

This commit is contained in:
Nabin Hait 2015-05-04 13:01:44 +05:30
parent c91a9e5231
commit 72f71836d7

View File

@ -19,6 +19,8 @@ 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 = frappe.new_doc("Account")
account.is_group = 0
account.update(args)
@ -47,6 +49,9 @@ def create_receivable_payable_account():
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:
@ -73,7 +78,8 @@ def set_party_in_jv_and_gl_entry(receivable_payable_accounts):
return
for dt in ["Journal Entry Account", "GL Entry"]:
records = frappe.db.sql("""select name, account from `tab%s` where account in (%s)""" %
records = frappe.db.sql("""select name, account from `tab%s`
where account in (%s) and ifnull(party, '') != ''""" %
(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, {})