From c257ce82c5a8897247a2ee8c132110329a96858f Mon Sep 17 00:00:00 2001 From: hendrik Date: Thu, 5 Sep 2019 16:44:09 +0700 Subject: [PATCH] Party accounts if don't have default company (#18771) Add check for get_default company --- erpnext/accounts/party.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 26c2950f3a7..59936d5116d 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -292,8 +292,11 @@ def validate_party_accounts(doc): party_account_currency = frappe.db.get_value("Account", account.account, "account_currency", cache=True) existing_gle_currency = get_party_gle_currency(doc.doctype, doc.name, account.company) - company_default_currency = frappe.get_cached_value('Company', - frappe.db.get_default("Company"), "default_currency") + if frappe.db.get_default("Company"): + company_default_currency = frappe.get_cached_value('Company', + frappe.db.get_default("Company"), "default_currency") + else: + company_default_currency = frappe.db.get_value('Company', account.company, "default_currency") if existing_gle_currency and party_account_currency != existing_gle_currency: frappe.throw(_("Accounting entries have already been made in currency {0} for company {1}. Please select a receivable or payable account with currency {0}.").format(existing_gle_currency, account.company)) @@ -607,4 +610,4 @@ def get_partywise_advanced_payment_amount(party_type, posting_date = None): .format(("credit") if party_type == "Customer" else "debit", cond) , party_type) if data: - return frappe._dict(data) \ No newline at end of file + return frappe._dict(data)