[ux] bom fixes #3072
diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js
index edfa438..699b272 100644
--- a/erpnext/manufacturing/doctype/bom/bom.js
+++ b/erpnext/manufacturing/doctype/bom/bom.js
@@ -8,8 +8,7 @@
toggle_operations(cur_frm);
if (!doc.__islocal && doc.docstatus<2) {
- cur_frm.add_custom_button(__("Update Cost"), cur_frm.cscript.update_cost,
- "icon-money", "btn-default");
+ cur_frm.add_custom_button(__("Update Cost"), cur_frm.cscript.update_cost);
}
}
@@ -17,6 +16,7 @@
return frappe.call({
doc: cur_frm.doc,
method: "update_cost",
+ freeze: true,
callback: function(r) {
if(!r.exc) cur_frm.refresh_fields();
}
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 36854b2..14932d2 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -123,7 +123,7 @@
def update_cost(self):
if self.docstatus == 2:
return
-
+
items_rate = frappe._dict()
for d in self.get("items"):
rate = self.get_bom_material_detail({'item_code': d.item_code, 'bom_no': d.bom_no,
@@ -131,16 +131,18 @@
if rate:
d.rate = rate
items_rate.setdefault(d.item_code, d.rate)
-
+
for e in self.get("exploded_items"):
if items_rate.get(e.item_code):
e.rate = items_rate.get(e.item_code)
-
+
if self.docstatus == 1:
self.flags.ignore_validate_update_after_submit = True
self.calculate_cost()
self.save()
+ frappe.msgprint(_("Cost Updated"))
+
def get_bom_unitcost(self, bom_no):
bom = frappe.db.sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
where is_active = 1 and name = %s""", bom_no, as_dict=1)