[fixes] added filters company and currency to get account, removed account name wise comparison
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 53a1b6a..36ff1ab 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -479,15 +479,13 @@
return outstanding_invoices
-def get_account(account_type=None, root_type=None, is_group=None, account_name=None):
+def get_account(account_type=None, root_type=None, is_group=None, account_currency=None, company=None):
"""return account based on matching conditions"""
- if account_name:
- if not frappe.db.get_value("Account", {"account_name": account_name}):
- return False
- else:
- return frappe.get_doc("Account", {
- "account_type": account_type or '',
- "root_type": root_type or '',
- "is_group": is_group or 0,
- "account_name": account_name or ''
- })
\ No newline at end of file
+ return frappe.db.get_value("Account", {
+ "account_type": account_type or '',
+ "root_type": root_type or '',
+ "is_group": is_group or 0,
+ "account_currency": account_currency or frappe.defaults.get_defaults().currency,
+ "company": company or frappe.defaults.get_defaults().company
+ }, "name")
+
\ No newline at end of file
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index b4df27d..012aaf7 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -329,7 +329,8 @@
account_name = _("Debtors ({0})".format(payment_gateway_account_currency))
- debtors_account = get_account("Receivable", "Asset", is_group=0, account_name=account_name)
+ debtors_account = get_account("Receivable", "Asset", is_group=0,\
+ account_currency=payment_gateway_account_currency, company=cart_settings.company)
if not debtors_account:
debtors_account = frappe.get_doc({
@@ -337,8 +338,7 @@
"account_type": "Receivable",
"root_type": "Asset",
"is_group": 0,
- "parent_account": get_account(root_type="Asset", is_group=1, \
- account_name=_("Accounts Receivable")).name,
+ "parent_account": get_account(root_type="Asset", is_group=1, company=cart_settings.company),
"account_name": account_name,
"currency": payment_gateway_account_currency
}).insert(ignore_permissions=True)