From 508727a57a7248fae0a72b9c521dba7e7dbfdaec Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 19 Mar 2025 12:52:34 +0530 Subject: [PATCH 1/2] fix: fetch bom_no when updating items in sales order --- erpnext/controllers/accounts_controller.py | 3 +++ erpnext/public/js/utils.js | 2 ++ erpnext/stock/get_item_details.py | 1 + 3 files changed, 6 insertions(+) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index e7d0ac994f7..7cea8176633 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -3731,6 +3731,9 @@ def update_child_qty_rate(parent_doctype, trans_items, parent_doctype_name, chil if d.get("schedule_date") and parent_doctype == "Purchase Order": child_item.schedule_date = d.get("schedule_date") + if d.get("bom_no") and parent_doctype == "Sales Order": + child_item.bom_no = d.get("bom_no") + if flt(child_item.price_list_rate): if flt(child_item.rate) > flt(child_item.price_list_rate): # if rate is greater than price_list_rate, set margin diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index a77d96575eb..c4e4af78f3d 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -713,6 +713,7 @@ erpnext.utils.update_child_items = function (opts) { uom, conversion_factor, item_name, + default_bom, } = r.message; const row = dialog.fields_dict.trans_items.df.data.find( @@ -725,6 +726,7 @@ erpnext.utils.update_child_items = function (opts) { qty: me.doc.qty || qty, rate: me.doc.rate || rate, item_name: item_name, + bom_no: default_bom, }); dialog.fields_dict.trans_items.grid.refresh(); } diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 37fbf73533c..a671d91ff33 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -479,6 +479,7 @@ def get_basic_details(ctx: ItemDetailsCtx, item, overwrite_warehouse=True) -> It "weight_per_unit": ctx.weight_per_unit or item.get("weight_per_unit"), "weight_uom": ctx.weight_uom or item.get("weight_uom"), "grant_commission": item.get("grant_commission"), + "default_bom": item.default_bom, } ) From 386df968c2647bfed9a388833e2f9cf7618228f2 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 19 Mar 2025 15:25:50 +0530 Subject: [PATCH 2/2] fix: remove duplicate --- erpnext/public/js/utils.js | 4 ++-- erpnext/stock/get_item_details.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index c4e4af78f3d..110109b691b 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -713,7 +713,7 @@ erpnext.utils.update_child_items = function (opts) { uom, conversion_factor, item_name, - default_bom, + bom_no, } = r.message; const row = dialog.fields_dict.trans_items.df.data.find( @@ -726,7 +726,7 @@ erpnext.utils.update_child_items = function (opts) { qty: me.doc.qty || qty, rate: me.doc.rate || rate, item_name: item_name, - bom_no: default_bom, + bom_no: bom_no, }); dialog.fields_dict.trans_items.grid.refresh(); } diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index a671d91ff33..37fbf73533c 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -479,7 +479,6 @@ def get_basic_details(ctx: ItemDetailsCtx, item, overwrite_warehouse=True) -> It "weight_per_unit": ctx.weight_per_unit or item.get("weight_per_unit"), "weight_uom": ctx.weight_uom or item.get("weight_uom"), "grant_commission": item.get("grant_commission"), - "default_bom": item.default_bom, } )