brotherton-erpnext/erpnext/patches/v4_2/reset_bom_costs.py

18 lines
547 B
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2014-12-10 10:17:25 +00:00
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
2014-12-18 06:06:23 +00:00
frappe.reload_doc('manufacturing', 'doctype', 'bom_operation')
2014-12-31 08:00:36 +00:00
for d in frappe.db.sql("""select name from `tabBOM` where docstatus < 2""", as_dict=1):
2014-12-10 10:17:25 +00:00
try:
bom = frappe.get_doc('BOM', d.name)
bom.flags.ignore_validate_update_after_submit = True
2014-12-10 10:17:25 +00:00
bom.calculate_cost()
bom.save()
frappe.db.commit()
except:
frappe.db.rollback()