From 5e7f8fd1562b531cc6a5f2384baf35e287579035 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 14 Apr 2015 14:24:21 +0530 Subject: [PATCH] [ux] bom fixes #3072 --- erpnext/manufacturing/doctype/bom/bom.js | 4 ++-- erpnext/manufacturing/doctype/bom/bom.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index edfa4381f3..699b272f23 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -8,8 +8,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn){ 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 @@ cur_frm.cscript.update_cost = function() { 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 36854b2d05..14932d28fe 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -123,7 +123,7 @@ class BOM(Document): 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 @@ class BOM(Document): 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)