fix: don't allow to update Maintain Stock if the item has a BOM

(cherry picked from commit 6d0842465b)
This commit is contained in:
Sagar Sharma
2022-09-30 15:18:10 +05:30
committed by Mergify
parent 7243089027
commit e5d1f59d96

View File

@@ -937,17 +937,21 @@ class Item(Document):
"Purchase Order Item", "Purchase Order Item",
"Material Request Item", "Material Request Item",
"Product Bundle", "Product Bundle",
"BOM",
] ]
for doctype in linked_doctypes: for doctype in linked_doctypes:
filters = {"item_code": self.name, "docstatus": 1} filters = {"item_code": self.name, "docstatus": 1}
if doctype in ("Product Bundle", "BOM"):
if doctype == "Product Bundle": if doctype == "Product Bundle":
filters = {"new_item_code": self.name} filters = {"new_item_code": self.name}
fieldname = "new_item_code as docname"
else:
filters = {"item": self.name, "docstatus": 1}
fieldname = "name as docname"
if linked_doc := frappe.db.get_value( if linked_doc := frappe.db.get_value(doctype, filters, fieldname, as_dict=True):
doctype, filters, ["new_item_code as docname"], as_dict=True
):
return linked_doc.update({"doctype": doctype}) return linked_doc.update({"doctype": doctype})
elif doctype in ( elif doctype in (