fix: optimize patch for update bom in SO and MR

(cherry picked from commit d9b9f4e8b7)
This commit is contained in:
Rohit Waghchaure
2021-12-29 10:14:03 +05:30
committed by mergify-bot
parent 098b3614e1
commit 9d575e6e27

View File

@@ -7,7 +7,7 @@ def execute():
frappe.reload_doc("selling", "doctype", "sales_order_item")
for doctype in ["Sales Order", "Material Request"]:
condition = " and child_doc.stock_qty > child_doc.produced_qty"
condition = " and child_doc.stock_qty > child_doc.produced_qty and doc.per_delivered < 100"
if doctype == "Material Request":
condition = " and doc.per_ordered < 100 and doc.material_request_type = 'Manufacture'"
@@ -16,5 +16,6 @@ def execute():
child_doc.bom_no = item.default_bom
WHERE
child_doc.item_code = item.name and child_doc.docstatus < 2
and child_doc.parent = doc.name
and item.default_bom is not null and item.default_bom != '' {cond}
""".format(doc = doctype, cond = condition))