From f5be350eb426a3c28908f51ee8ae3d75a7e92da4 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Thu, 29 Jan 2015 12:21:42 +0530 Subject: [PATCH 1/2] Validations added to Bom Doctype. --- erpnext/manufacturing/doctype/bom/bom.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 5c4a841fc5..6160a07b9c 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -32,6 +32,7 @@ class BOM(Document): self.validate_materials() self.set_bom_material_details() self.calculate_cost() + self.validate_operations() def on_update(self): self.check_recursion() @@ -209,6 +210,8 @@ class BOM(Document): def validate_materials(self): """ Validate raw material entries """ + if self.get('items') == []: + frappe.throw(_("Raw Materials cannot be blank.")) check_list = [] for m in self.get('items'): @@ -365,6 +368,10 @@ class BOM(Document): if act_pbom and act_pbom[0][0]: frappe.throw(_("Cannot deactivate or cancel BOM as it is linked with other BOMs")) + + def validate_operations(self): + if self.with_operations and self.get('operations') == []: + frappe.throw(_("Operations cannot be left blank.")) def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1): item_dict = {} From 9257baa74776a3baa0ae284f53578bc520510d7d Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 3 Feb 2015 12:29:36 +0530 Subject: [PATCH 2/2] fixes in bom validations --- erpnext/manufacturing/doctype/bom/bom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 6160a07b9c..1ef1f7e9e6 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -210,7 +210,7 @@ class BOM(Document): def validate_materials(self): """ Validate raw material entries """ - if self.get('items') == []: + if not self.get('items'): frappe.throw(_("Raw Materials cannot be blank.")) check_list = [] for m in self.get('items'): @@ -370,7 +370,7 @@ class BOM(Document): frappe.throw(_("Cannot deactivate or cancel BOM as it is linked with other BOMs")) def validate_operations(self): - if self.with_operations and self.get('operations') == []: + if self.with_operations and not self.get('operations'): frappe.throw(_("Operations cannot be left blank.")) def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1):