* perf: use `LEFT JOIN` instead of `NOT EXISTS` (cherry picked from commit58d867503b) # Conflicts: # erpnext/manufacturing/doctype/bom_update_log/bom_updation_utils.py * fix: long queue `process_boms_cost_level_wise` (cherry picked from commit148d466ae5) * chore: `conflicts` * fix: failing test case --------- Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
@@ -79,6 +79,7 @@ class BOMUpdateLog(Document):
|
|||||||
else:
|
else:
|
||||||
frappe.enqueue(
|
frappe.enqueue(
|
||||||
method="erpnext.manufacturing.doctype.bom_update_log.bom_update_log.process_boms_cost_level_wise",
|
method="erpnext.manufacturing.doctype.bom_update_log.bom_update_log.process_boms_cost_level_wise",
|
||||||
|
queue="long",
|
||||||
update_doc=self,
|
update_doc=self,
|
||||||
now=frappe.flags.in_test,
|
now=frappe.flags.in_test,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -157,12 +157,21 @@ def get_next_higher_level_boms(
|
|||||||
def get_leaf_boms() -> List[str]:
|
def get_leaf_boms() -> List[str]:
|
||||||
"Get BOMs that have no dependencies."
|
"Get BOMs that have no dependencies."
|
||||||
|
|
||||||
return frappe.db.sql_list(
|
bom = frappe.qb.DocType("BOM")
|
||||||
"""select name from `tabBOM` bom
|
bom_item = frappe.qb.DocType("BOM Item")
|
||||||
where docstatus=1 and is_active=1
|
|
||||||
and not exists(select bom_no from `tabBOM Item`
|
boms = (
|
||||||
where parent=bom.name and ifnull(bom_no, '')!='')"""
|
frappe.qb.from_(bom)
|
||||||
)
|
.left_join(bom_item)
|
||||||
|
.on((bom.name == bom_item.parent) & (bom_item.bom_no != ""))
|
||||||
|
.select(bom.name)
|
||||||
|
.where((bom.docstatus == 1) & (bom.is_active == 1) & (bom_item.bom_no.isnull()))
|
||||||
|
.distinct()
|
||||||
|
).run(as_list=True)
|
||||||
|
|
||||||
|
boms = [bom[0] for bom in boms]
|
||||||
|
|
||||||
|
return boms
|
||||||
|
|
||||||
|
|
||||||
def _generate_dependence_map() -> defaultdict:
|
def _generate_dependence_map() -> defaultdict:
|
||||||
|
|||||||
Reference in New Issue
Block a user