[ux] bom fixes #3072
This commit is contained in:
parent
de9bd108d0
commit
5e7f8fd156
@ -8,8 +8,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn){
|
|||||||
toggle_operations(cur_frm);
|
toggle_operations(cur_frm);
|
||||||
|
|
||||||
if (!doc.__islocal && doc.docstatus<2) {
|
if (!doc.__islocal && doc.docstatus<2) {
|
||||||
cur_frm.add_custom_button(__("Update Cost"), cur_frm.cscript.update_cost,
|
cur_frm.add_custom_button(__("Update Cost"), cur_frm.cscript.update_cost);
|
||||||
"icon-money", "btn-default");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,6 +16,7 @@ cur_frm.cscript.update_cost = function() {
|
|||||||
return frappe.call({
|
return frappe.call({
|
||||||
doc: cur_frm.doc,
|
doc: cur_frm.doc,
|
||||||
method: "update_cost",
|
method: "update_cost",
|
||||||
|
freeze: true,
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc) cur_frm.refresh_fields();
|
if(!r.exc) cur_frm.refresh_fields();
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ class BOM(Document):
|
|||||||
def update_cost(self):
|
def update_cost(self):
|
||||||
if self.docstatus == 2:
|
if self.docstatus == 2:
|
||||||
return
|
return
|
||||||
|
|
||||||
items_rate = frappe._dict()
|
items_rate = frappe._dict()
|
||||||
for d in self.get("items"):
|
for d in self.get("items"):
|
||||||
rate = self.get_bom_material_detail({'item_code': d.item_code, 'bom_no': d.bom_no,
|
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:
|
if rate:
|
||||||
d.rate = rate
|
d.rate = rate
|
||||||
items_rate.setdefault(d.item_code, d.rate)
|
items_rate.setdefault(d.item_code, d.rate)
|
||||||
|
|
||||||
for e in self.get("exploded_items"):
|
for e in self.get("exploded_items"):
|
||||||
if items_rate.get(e.item_code):
|
if items_rate.get(e.item_code):
|
||||||
e.rate = items_rate.get(e.item_code)
|
e.rate = items_rate.get(e.item_code)
|
||||||
|
|
||||||
if self.docstatus == 1:
|
if self.docstatus == 1:
|
||||||
self.flags.ignore_validate_update_after_submit = True
|
self.flags.ignore_validate_update_after_submit = True
|
||||||
self.calculate_cost()
|
self.calculate_cost()
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
frappe.msgprint(_("Cost Updated"))
|
||||||
|
|
||||||
def get_bom_unitcost(self, bom_no):
|
def get_bom_unitcost(self, bom_no):
|
||||||
bom = frappe.db.sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
|
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)
|
where is_active = 1 and name = %s""", bom_no, as_dict=1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user