fix(patch): handle duplicate entry error while inserting account (#22745)
This commit is contained in:
parent
514366654e
commit
3d3c922d7f
@ -100,6 +100,8 @@ def get_item_tax_template(item_tax_templates, item_tax_map, item_code, parenttyp
|
|||||||
tax_type = None
|
tax_type = None
|
||||||
else:
|
else:
|
||||||
company = get_company(parts[-1], parenttype, parent)
|
company = get_company(parts[-1], parenttype, parent)
|
||||||
|
parent_account = frappe.get_value("Account", {"account_name": account_name, "company": company}, "parent_account")
|
||||||
|
if not parent_account:
|
||||||
parent_account = frappe.db.get_value("Account",
|
parent_account = frappe.db.get_value("Account",
|
||||||
filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0, "company": company}, fieldname="parent_account")
|
filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0, "company": company}, fieldname="parent_account")
|
||||||
if not parent_account:
|
if not parent_account:
|
||||||
@ -115,8 +117,11 @@ def get_item_tax_template(item_tax_templates, item_tax_map, item_code, parenttyp
|
|||||||
if not tax_type:
|
if not tax_type:
|
||||||
account = frappe.new_doc("Account")
|
account = frappe.new_doc("Account")
|
||||||
account.update(filters)
|
account.update(filters)
|
||||||
|
try:
|
||||||
account.insert()
|
account.insert()
|
||||||
tax_type = account.name
|
tax_type = account.name
|
||||||
|
except frappe.DuplicateEntryError:
|
||||||
|
tax_type = frappe.db.get_value("Account", {"account_name": account_name, "company": company}, "name")
|
||||||
|
|
||||||
account_type = frappe.get_cached_value("Account", tax_type, "account_type")
|
account_type = frappe.get_cached_value("Account", tax_type, "account_type")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user