def manage_default_bom(self): """ Uncheck others if current one is selected as default, update default bom in item master """ if self.is_default and self.is_active: from frappe.model.utils import set_default set_default(self, "item") frappe.db.set_value("Item", self.item, "default_bom", self.name) else: if not self.is_active: frappe.db.set(self, "is_default", 0) frappe.db.sql("update `tabItem` set default_bom = null where name = %s and default_bom = %s", (self.item, self.name))
def manage_default_bom(self): """ Uncheck others if current one is selected as default, update default bom in item master """ if self.is_default and self.is_active: from frappe.model.utils import set_default set_default(self, "item") item = frappe.get_doc("Item", self.item) if item.default_bom != self.name: frappe.db.set_value('Item', self.item, 'default_bom', self.name) else: frappe.db.set(self, "is_default", 0) item = frappe.get_doc("Item", self.item) if item.default_bom == self.name: frappe.db.set_value('Item', self.item, 'default_bom', None)
def manage_default_bom(self): """ Uncheck others if current one is selected as default, update default bom in item master """ if self.is_default and self.is_active: from frappe.model.utils import set_default set_default(self, "item") item = frappe.get_doc("Item", self.item) if item.default_bom != self.name: item.default_bom = self.name item.save(ignore_permissions=True) else: frappe.db.set(self, "is_default", 0) item = frappe.get_doc("Item", self.item) if item.default_bom == self.name: item.default_bom = None item.save(ignore_permissions=True)
def manage_default_bom(self): """ Uncheck others if current one is selected as default, update default bom in item master """ if self.is_default and self.is_active: from frappe.model.utils import set_default set_default(self, "item") item = frappe.get_doc("Item", self.item) if item.default_bom != self.name: item.default_bom = self.name item.save(ignore_permissions = True) else: frappe.db.set(self, "is_default", 0) item = frappe.get_doc("Item", self.item) if item.default_bom == self.name: item.default_bom = None item.save(ignore_permissions = True)
def manage_default_bom(self): """ Uncheck others if current one is selected as default or check the current one as default if it the only bom for the selected item, update default bom in item master """ if self.is_default and self.is_active: from frappe.model.utils import set_default set_default(self, "item") item = frappe.get_doc("Item", self.item) if item.default_bom != self.name: frappe.db.set_value('Item', self.item, 'default_bom', self.name) elif not frappe.db.exists(dict(doctype='BOM', docstatus=1, item=self.item, is_default=1)) \ and self.is_active: frappe.db.set(self, "is_default", 1) else: frappe.db.set(self, "is_default", 0) item = frappe.get_doc("Item", self.item) if item.default_bom == self.name: frappe.db.set_value('Item', self.item, 'default_bom', None)