[Fix] BOM update tool, too many writes in one request. Please send smaller requests (#15432)

This commit is contained in:
rohitwaghchaure
2018-09-25 18:59:20 +05:30
committed by Nabin Hait
parent fe1e4a41e6
commit fafc277666
2 changed files with 17 additions and 10 deletions

View File

@@ -506,7 +506,7 @@ def save_invoice(doc, name, name_list):
frappe.db.commit() frappe.db.commit()
name_list.append(name) name_list.append(name)
except Exception: except Exception:
frappe.log_error(frappe.get_traceback())
frappe.db.rollback() frappe.db.rollback()
frappe.log_error(frappe.get_traceback())
return name_list return name_list

View File

@@ -16,7 +16,9 @@ class BOMUpdateTool(Document):
self.update_new_bom() self.update_new_bom()
bom_list = self.get_parent_boms(self.new_bom) bom_list = self.get_parent_boms(self.new_bom)
updated_bom = [] updated_bom = []
for bom in bom_list: for bom in bom_list:
try:
bom_obj = frappe.get_doc("BOM", bom) bom_obj = frappe.get_doc("BOM", bom)
bom_obj.get_doc_before_save() bom_obj.get_doc_before_save()
updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom) updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom)
@@ -27,6 +29,11 @@ class BOMUpdateTool(Document):
and bom_obj._doc_before_save and not bom_obj.flags.ignore_version): and bom_obj._doc_before_save and not bom_obj.flags.ignore_version):
bom_obj.save_version() bom_obj.save_version()
frappe.db.commit()
except Exception:
frappe.db.rollback()
frappe.log_error(frappe.get_traceback())
def validate_bom(self): def validate_bom(self):
if cstr(self.current_bom) == cstr(self.new_bom): if cstr(self.current_bom) == cstr(self.new_bom):
frappe.throw(_("Current BOM and New BOM can not be same")) frappe.throw(_("Current BOM and New BOM can not be same"))