[fix] Update bom item description (#11498)
* [fix] Update bom item description
* Update item.py
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 844d62b..6a6af3d 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -91,7 +91,7 @@
self.validate_barcode()
self.cant_change()
self.validate_warehouse_for_reorder()
- self.update_item_desc()
+ self.update_bom_item_desc()
self.synced_with_hub = 0
self.validate_has_variants()
@@ -599,13 +599,27 @@
row.label = label
row.description = desc
- def update_item_desc(self):
- if frappe.db.get_value('BOM',self.name, 'description') != self.description:
- frappe.db.sql("""update `tabBOM` set description = %s where item = %s and docstatus < 2""",(self.description, self.name))
- frappe.db.sql("""update `tabBOM Item` set description = %s where
- item_code = %s and docstatus < 2""",(self.description, self.name))
- frappe.db.sql("""update `tabBOM Explosion Item` set description = %s where
- item_code = %s and docstatus < 2""",(self.description, self.name))
+ def update_bom_item_desc(self):
+ if self.is_new(): return
+
+ if self.db_get('description') != self.description:
+ frappe.db.sql("""
+ update `tabBOM`
+ set description = %s
+ where item = %s and docstatus < 2
+ """, (self.description, self.name))
+
+ frappe.db.sql("""
+ update `tabBOM Item`
+ set description = %s
+ where item_code = %s and docstatus < 2
+ """, (self.description, self.name))
+
+ frappe.db.sql("""
+ update `tabBOM Explosion Item`
+ set description = %s
+ where item_code = %s and docstatus < 2
+ """, (self.description, self.name))
def update_template_item(self):
"""Set Show in Website for Template Item if True for its Variant"""