fix(stock): fetch bom raw materials for manufacture entries without a work order

splitting stock_entry.py into services dropped the work order guard, so a standalone manufacture or material consumption entry read skip_transfer on a missing work order and crashed get_items whenever backflush was material transferred for manufacture. follow the bom in that case as before.
This commit is contained in:
Sudharsanan11
2026-10-29 15:12:29 +05:30
parent 3dd79e75a9
commit 8f40bec4f5
@@ -518,6 +518,11 @@ class ManufactureStockEntry(BaseManufactureStockEntry):
self.add_secondary_items_from_job_card()
def add_raw_materials(self):
if not self.wo_doc:
# nothing was transferred or consumed for a standalone entry, so follow the BOM
self.add_raw_materials_based_on_work_order()
return
material_consumption = frappe.db.get_single_value("Manufacturing Settings", "material_consumption")
if material_consumption and self.raw_materials_already_consumed():
@@ -1333,7 +1338,7 @@ class MaterialConsumptionForManufactureStockEntry(ManufactureStockEntry):
self.validate_alternative_items()
def add_items(self):
if self.backflush_based_on == "BOM" or self.wo_doc.skip_transfer:
if self.backflush_based_on == "BOM" or not self.wo_doc or self.wo_doc.skip_transfer:
self.add_raw_materials_based_on_work_order()
else:
self.add_raw_materials_based_on_transfer()