Merge pull request #29064 from rohitwaghchaure/optimize-patch-for-update-bom-in-so-mr

fix: optimize patch for update bom in SO and MR
This commit is contained in:
rohitwaghchaure 2021-12-29 12:08:27 +05:30 committed by GitHub
commit 56b9ad8303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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