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

17 lines
515 B
Python
Raw Normal View History

2014-12-10 10:17:25 +00:00
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
for d in frappe.db.sql("""select name from `tabBOM` where docstatus < 2 and total_fixed_cost IS NOT NULL""", as_dict=1):
try:
bom = frappe.get_doc('BOM', d.name)
bom.ignore_validate_update_after_submit = True
bom.calculate_cost()
bom.save()
frappe.db.commit()
except:
frappe.db.rollback()