fix: hide with_operation on selection on fg_based and vice versa

(cherry picked from commit 694fc3e20c)
This commit is contained in:
Vishal
2023-01-11 18:52:30 +05:30
committed by Mergify
parent 19aa23765a
commit 8ee6db3b7b

View File

@@ -71,6 +71,14 @@ frappe.ui.form.on("BOM", {
}
},
with_operations: function(frm) {
frm.set_df_property("fg_based_operating_cost", "hidden", frm.doc.with_operations ? 1 : 0);
},
fg_based_operating_cost: function(frm) {
frm.set_df_property("with_operations", "hidden", frm.doc.fg_based_operating_cost ? 1 : 0);
},
onload_post_render: function(frm) {
frm.get_field("items").grid.set_multiple_add("item_code", "qty");
},
@@ -538,16 +546,17 @@ erpnext.bom.update_cost = function(doc) {
};
erpnext.bom.calculate_op_cost = function(doc) {
var op = doc.operations || [];
doc.operating_cost = 0.0;
doc.base_operating_cost = 0.0;
if(doc.with_operations) {
op.forEach((item) => {
doc.operations.forEach((item) => {
let operating_cost = flt(flt(item.hour_rate) * flt(item.time_in_mins) / 60, 2);
let base_operating_cost = flt(operating_cost * doc.conversion_rate, 2);
frappe.model.set_value('BOM Operation',item.name, "operating_cost", operating_cost);
frappe.model.set_value('BOM Operation',item.name, "base_operating_cost", base_operating_cost);
frappe.model.set_value('BOM Operation',item.name, {
"operating_cost": operating_cost,
"base_operating_cost": base_operating_cost
});
doc.operating_cost += operating_cost;
doc.base_operating_cost += base_operating_cost;