mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 00:14:50 +00:00
[fix] DuplicateEntryError for Warehouse Account Creation
This commit is contained in:
@@ -53,6 +53,7 @@ class Warehouse(NestedSet):
|
||||
if not self.get_account(self.name):
|
||||
if self.get("__islocal") or not frappe.db.get_value(
|
||||
"Stock Ledger Entry", {"warehouse": self.name}):
|
||||
|
||||
self.validate_parent_account()
|
||||
ac_doc = frappe.get_doc({
|
||||
"doctype": "Account",
|
||||
@@ -66,8 +67,15 @@ class Warehouse(NestedSet):
|
||||
"freeze_account": "No"
|
||||
})
|
||||
ac_doc.flags.ignore_permissions = True
|
||||
ac_doc.insert()
|
||||
msgprint(_("Account head {0} created").format(ac_doc.name))
|
||||
|
||||
try:
|
||||
ac_doc.insert()
|
||||
msgprint(_("Account head {0} created").format(ac_doc.name))
|
||||
|
||||
except frappe.DuplicateEntryError, e:
|
||||
if not (e.args and e.args[0]=='Account'):
|
||||
# if this is not due to creation of Account
|
||||
raise
|
||||
|
||||
def validate_parent_account(self):
|
||||
if not self.company:
|
||||
|
||||
Reference in New Issue
Block a user