fix: Load doc before save

This commit is contained in:
Nabin Hait 2019-04-23 13:13:16 +05:30
parent 77b82894ff
commit 319c912f91
3 changed files with 4 additions and 7 deletions

View File

@ -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()

View File

@ -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:

View File

@ -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
}