From 0adb7156cd4ee644897b85a7373b1a07125d082e Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 7 May 2025 11:10:23 +0530 Subject: [PATCH] fix: dont auto-fetch latest exchange rate - also use correct currency field for comparison (cherry picked from commit 4ccd0a740706c3bfa01ed25959580107d360aa60) --- erpnext/crm/doctype/opportunity/opportunity.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js index 1c8a80a0ed6..b78eae5f109 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.js +++ b/erpnext/crm/doctype/opportunity/opportunity.js @@ -111,6 +111,13 @@ frappe.ui.form.on("Opportunity", { }, __("Create") ); + + let company_currency = erpnext.get_currency(frm.doc.company); + if (company_currency != frm.doc.currency) { + frm.add_custom_button(__("Fetch Latest Exchange Rate"), function () { + frm.trigger("currency"); + }); + } } if (!frm.doc.__islocal && frm.perm[0].write && frm.doc.docstatus == 0) { @@ -152,7 +159,7 @@ frappe.ui.form.on("Opportunity", { currency: function (frm) { let company_currency = erpnext.get_currency(frm.doc.company); - if (company_currency != frm.doc.company) { + if (company_currency != frm.doc.currency) { frappe.call({ method: "erpnext.setup.utils.get_exchange_rate", args: { @@ -278,7 +285,6 @@ erpnext.crm.Opportunity = class Opportunity extends frappe.ui.form.Controller { } this.setup_queries(); - this.frm.trigger("currency"); } refresh() {