From 50b1fa5deb2a502782cac6884c4ed9f82b1cd335 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:20:04 +0530 Subject: [PATCH] fix: currency changing while making PR from the PO (backport #42718) (#42721) fix: currency changing while making PR from the PO (#42718) (cherry picked from commit 17ba0cff446737908cd9828d4776e35596f05764) Co-authored-by: rohitwaghchaure --- erpnext/public/js/controllers/transaction.js | 29 ++++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index bc20901ae1c..4696c7f3b4d 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -840,6 +840,10 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } var get_party_currency = function() { + if (me.is_a_mapped_document()) { + return; + } + var party_type = frappe.meta.has_field(me.frm.doc.doctype, "customer") ? "Customer" : "Supplier"; var party_name = me.frm.doc[party_type.toLowerCase()]; if (party_name) { @@ -1249,17 +1253,24 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe 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"], - "Sales Order Item": ["prevdoc_docname", "quotation_item"], + "Delivery Note": ["si_detail", "so_detail", "dn_detail"], + "Sales Invoice": ["dn_detail", "so_detail", "sales_invoice_item"], + "Purchase Receipt": ["purchase_order_item", "purchase_invoice_item", "purchase_receipt_item"], + "Purchase Invoice": ["purchase_order_item", "pr_detail", "po_detail"], + "Sales Order": ["prevdoc_docname", "quotation_item"], }; - const mappped_fields = mapped_item_field_map[item.doctype] || []; + const mappped_fields = mapped_item_field_map[this.frm.doc.doctype] || []; - return mappped_fields - .map((field) => item[field]) - .filter(Boolean).length > 0; + if (item) { + return mappped_fields + .map((field) => item[field]) + .filter(Boolean).length > 0; + } else if (this.frm.doc?.items) { + let first_row = this.frm.doc.items[0]; + let mapped_rows = mappped_fields.filter(d => first_row[d]) + + return mapped_rows?.length > 0; + } } batch_no(doc, cdt, cdn) {