From 319c912f910b8ef21bf12af952acefabf4066091 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 23 Apr 2019 13:13:16 +0530 Subject: [PATCH] fix: Load doc before save --- .../doctype/bom_update_tool/bom_update_tool.py | 7 +++---- erpnext/stock/doctype/item/item.py | 2 -- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py b/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py index 59861ceba3..a7d1d859dd 100644 --- a/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py +++ b/erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py @@ -20,13 +20,12 @@ class BOMUpdateTool(Document): for bom in bom_list: try: bom_obj = frappe.get_doc("BOM", bom) - bom_obj.get_doc_before_save() + bom_obj.load_doc_before_save() updated_bom = bom_obj.update_cost_and_exploded_items(updated_bom) bom_obj.calculate_cost() bom_obj.update_parent_cost() bom_obj.db_update() - if (getattr(bom_obj.meta, 'track_changes', False) - and bom_obj._doc_before_save and not bom_obj.flags.ignore_version): + if (getattr(bom_obj.meta, 'track_changes', False) and not bom_obj.flags.ignore_version): bom_obj.save_version() frappe.db.commit() @@ -37,7 +36,7 @@ class BOMUpdateTool(Document): def validate_bom(self): if cstr(self.current_bom) == cstr(self.new_bom): frappe.throw(_("Current BOM and New BOM can not be same")) - + if frappe.db.get_value("BOM", self.current_bom, "item") \ != frappe.db.get_value("BOM", self.new_bom, "item"): frappe.throw(_("The selected BOMs are not for the same item")) diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index aeab9ed978..ed02cee3a4 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -90,8 +90,6 @@ class Item(WebsiteGenerator): self.set_opening_stock() def validate(self): - self.get_doc_before_save() - super(Item, self).validate() if not self.item_name: diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index d7808c2695..47f2187b5c 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -729,7 +729,7 @@ class TestStockEntry(unittest.TestCase): make_stock_entry(item_code="_Test Item 2", target="_Test Warehouse - _TC", qty=50, basic_rate=20) item_quantity = { - '_Test Item': 10.0, + '_Test Item': 2.0, '_Test Item 2': 12.0, '_Test Serialized Item With Series': 6.0 }