From 694fc3e20c584a4c63ff339b0223b358ffa4f79e Mon Sep 17 00:00:00 2001 From: Vishal Date: Wed, 11 Jan 2023 18:52:30 +0530 Subject: [PATCH] fix: hide with_operation on selection on fg_based and vice versa --- erpnext/manufacturing/doctype/bom/bom.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js index b16847faf3..4304193afa 100644 --- a/erpnext/manufacturing/doctype/bom/bom.js +++ b/erpnext/manufacturing/doctype/bom/bom.js @@ -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;