Merge pull request #18037 from rohitwaghchaure/bom_update_tool_optimization

fix: optimize bom update tool
This commit is contained in:
rohitwaghchaure 2019-06-24 18:00:17 +05:30 committed by GitHub
commit 55c9eb6d9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -381,9 +381,12 @@ class BOM(WebsiteGenerator):
frappe.throw(_("Same item has been entered multiple times. {0}").format(duplicate_list))
def check_recursion(self):
def check_recursion(self, bom_list=[]):
""" Check whether recursion occurs in any bom"""
bom_list = self.traverse_tree()
if not bom_list:
bom_list = self.traverse_tree()
bom_nos = frappe.get_all('BOM Item', fields=["bom_no"],
filters={'parent': ('in', bom_list), 'parenttype': 'BOM'})
@ -405,7 +408,7 @@ class BOM(WebsiteGenerator):
bom_list = self.traverse_tree(bom_list)
for bom in bom_list:
bom_obj = frappe.get_doc("BOM", bom)
bom_obj.check_recursion()
bom_obj.check_recursion(bom_list=bom_list)
bom_obj.update_exploded_items()
return bom_list

View File

@ -55,7 +55,7 @@ class BOMUpdateTool(Document):
bom_list = []
data = frappe.db.sql(""" select distinct parent from `tabBOM Item`
where ifnull(bom_no, '') = %s and docstatus < 2 and parenttype='BOM'""", bom)
where bom_no = %s and docstatus < 2 and parenttype='BOM'""", bom)
for d in data:
bom_list.append(d[0])