[feature] [bom] update cost button
This commit is contained in:
parent
d23e5c8a9a
commit
dab1cf9f6c
@ -20,12 +20,23 @@ cur_frm.cscript.refresh = function(doc,dt,dn){
|
||||
|
||||
if (!doc.__islocal && doc.docstatus==0) {
|
||||
cur_frm.set_intro("Submit the BOM to use it for manufacturing or repacking.");
|
||||
cur_frm.add_custom_button("Update Cost", cur_frm.cscript.update_cost);
|
||||
} else cur_frm.set_intro("");
|
||||
|
||||
cur_frm.cscript.with_operations(doc);
|
||||
set_operation_no(doc);
|
||||
}
|
||||
|
||||
cur_frm.cscript.update_cost = function() {
|
||||
wn.call({
|
||||
doc: cur_frm.doc,
|
||||
method: "update_cost",
|
||||
callback: function(r) {
|
||||
if(!r.exc) cur_frm.refresh_fields();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
cur_frm.cscript.with_operations = function(doc) {
|
||||
cur_frm.fields_dict["bom_materials"].grid.set_column_disp("operation_no", doc.with_operations);
|
||||
cur_frm.fields_dict["bom_materials"].grid.toggle_reqd("operation_no", doc.with_operations)
|
||||
|
@ -135,6 +135,17 @@ class DocType:
|
||||
rate = arg['standard_rate']
|
||||
|
||||
return rate
|
||||
|
||||
def update_cost(self):
|
||||
for d in self.doclist.get({"parentfield": "bom_materials"}):
|
||||
d.rate = self.get_bom_material_detail({
|
||||
'item_code': d.item_code,
|
||||
'bom_no': d.bom_no,
|
||||
'qty': d.qty
|
||||
})["rate"]
|
||||
|
||||
self.on_update()
|
||||
|
||||
|
||||
def get_bom_unitcost(self, bom_no):
|
||||
bom = sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
|
||||
|
Loading…
Reference in New Issue
Block a user