From 31fd263825a811942d20e6a48b8d92c07b642f7d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 4 Jul 2022 17:02:11 +0530 Subject: [PATCH] fix(UX): dont apply price list when changing batch on mapped docs (backport #31503) (#31504) fix(UX): dont apply price list when changing batch on mapped docs (#31503) fix(UX): dont apply price list batch change on mapped docs (cherry picked from commit 7e40c86c56c81abbbfa23ef79b7e14b9a6a47090) Co-authored-by: Ankush Menat --- erpnext/public/js/controllers/transaction.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index 3a51dd1a261..b83d5a8d7ae 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -1223,9 +1223,25 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({ } }, + is_a_mapped_document(item) { + const mapped_item_field_map = { + "Delivery Note Item": ["si_detail", "so_detail", "dn_detail"], + "Sales Invoice Item": ["dn_detail", "so_detail", "sales_invoice_item"], + "Purchase Receipt Item": ["purchase_order_item", "purchase_invoice_item", "purchase_receipt_item"], + "Purchase Invoice Item": ["purchase_order_item", "pr_detail", "po_detail"], + }; + const mappped_fields = mapped_item_field_map[item.doctype] || []; + + return mappped_fields + .map((field) => item[field]) + .filter(Boolean).length > 0; + }, + batch_no: function(doc, cdt, cdn) { let item = frappe.get_doc(cdt, cdn); - this.apply_price_list(item, true); + if (!this.is_a_mapped_document(item)) { + this.apply_price_list(item, true); + } }, toggle_conversion_factor: function(item) {