diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index cb96478735..1b1dc62fb1 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -83,6 +83,7 @@ cur_frm.cscript.hour_rate = function(doc, dt, dn) { cur_frm.cscript.time_in_mins = cur_frm.cscript.hour_rate; +cur_frm.cscript.fixed_cycle_cost = cur_frm.cscript.hour_rate; cur_frm.cscript.item_code = function(doc, cdt, cdn) { get_bom_material_detail(doc, cdt, cdn); diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index e8a8682ceb..199ade94c4 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -285,7 +285,10 @@ class BOM(Document): if not d.hour_rate: d.hour_rate = flt(w[0]) - fixed_cost += flt(w[1]) + if d.fixed_cycle_cost == None: + d.fixed_cycle_cost= flt(w[1]) + + fixed_cost += d.fixed_cycle_cost if d.hour_rate and d.time_in_mins: d.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60.0 diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 4c975815c5..33fa396649 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -89,3 +89,4 @@ erpnext.patches.v4_2.recalculate_bom_cost erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions erpnext.patches.v4_2.update_requested_and_ordered_qty execute:frappe.delete_doc("DocType", "Contact Control") +erpnext.patches.v4_2.recalculate_bom_costs diff --git a/erpnext/patches/v4_2/recalculate_bom_costs.py b/erpnext/patches/v4_2/recalculate_bom_costs.py new file mode 100644 index 0000000000..8c887a83f0 --- /dev/null +++ b/erpnext/patches/v4_2/recalculate_bom_costs.py @@ -0,0 +1,17 @@ +# 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() + \ No newline at end of file