Merge pull request #36709 from s-aga-r/FIX-36695

fix: don't throw if item does not have default BOM
This commit is contained in:
s-aga-r 2023-08-21 14:43:03 +05:30 committed by GitHub
commit 450949cadd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -347,7 +347,7 @@ class ProductionPlan(Document):
if not data.pending_qty: if not data.pending_qty:
continue continue
item_details = get_item_details(data.item_code) item_details = get_item_details(data.item_code, throw=False)
if self.combine_items: if self.combine_items:
if item_details.bom_no in refs: if item_details.bom_no in refs:
refs[item_details.bom_no]["so_details"].append( refs[item_details.bom_no]["so_details"].append(
@ -795,6 +795,9 @@ class ProductionPlan(Document):
if not row.item_code: if not row.item_code:
frappe.throw(_("Row #{0}: Please select Item Code in Assembly Items").format(row.idx)) frappe.throw(_("Row #{0}: Please select Item Code in Assembly Items").format(row.idx))
if not row.bom_no:
frappe.throw(_("Row #{0}: Please select the BOM No in Assembly Items").format(row.idx))
bom_data = [] bom_data = []
warehouse = row.warehouse if self.skip_available_sub_assembly_item else None warehouse = row.warehouse if self.skip_available_sub_assembly_item else None

View File

@ -1082,7 +1082,7 @@ def get_bom_operations(doctype, txt, searchfield, start, page_len, filters):
@frappe.whitelist() @frappe.whitelist()
def get_item_details(item, project=None, skip_bom_info=False): def get_item_details(item, project=None, skip_bom_info=False, throw=True):
res = frappe.db.sql( res = frappe.db.sql(
""" """
select stock_uom, description, item_name, allow_alternative_item, select stock_uom, description, item_name, allow_alternative_item,
@ -1118,12 +1118,15 @@ def get_item_details(item, project=None, skip_bom_info=False):
if not res["bom_no"]: if not res["bom_no"]:
if project: if project:
res = get_item_details(item) res = get_item_details(item, throw=throw)
frappe.msgprint( frappe.msgprint(
_("Default BOM not found for Item {0} and Project {1}").format(item, project), alert=1 _("Default BOM not found for Item {0} and Project {1}").format(item, project), alert=1
) )
else: else:
frappe.throw(_("Default BOM for {0} not found").format(item)) msg = _("Default BOM for {0} not found").format(item)
frappe.msgprint(msg, raise_exception=throw, indicator="yellow", alert=(not throw))
return res
bom_data = frappe.db.get_value( bom_data = frappe.db.get_value(
"BOM", "BOM",