From 5f299a08bd38c1a080636724dc035bedafb9e4d7 Mon Sep 17 00:00:00 2001 From: Marica Date: Mon, 6 Jul 2020 18:26:56 +0530 Subject: [PATCH] fix: General Message in previous doc validation for buying and selling (#22546) --- erpnext/utilities/transaction_base.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 2359648c95..5bf85d1c64 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -120,6 +120,16 @@ class TransactionBase(StatusUpdater): def validate_rate_with_reference_doc(self, ref_details): + buying_doctypes = ["Purchase Order", "Purchase Invoice", "Purchase Receipt"] + selling_doctypes = ["Sales Invoice", "Delivery Note"] + + if self.doctype in buying_doctypes: + to_disable = "Maintain same rate throughout Purchase cycle" + settings_page = "Buying Settings" + else: + to_disable = "Maintain same rate throughout Sales cycle" + settings_page = "Selling Settings" + for ref_dt, ref_dn_field, ref_link_field in ref_details: for d in self.get("items"): if d.get(ref_link_field): @@ -129,8 +139,8 @@ class TransactionBase(StatusUpdater): frappe.msgprint(_("Row #{0}: Rate must be same as {1}: {2} ({3} / {4}) ") .format(d.idx, ref_dt, d.get(ref_dn_field), d.rate, ref_rate)) frappe.throw(_("To allow different rates, disable the {0} checkbox in {1}.") - .format(frappe.bold(_("Maintain Same Rate Throughout Sales Cycle")), - get_link_to_form("Selling Settings", "Selling Settings", frappe.bold("Selling Settings")))) + .format(frappe.bold(_(to_disable)), + get_link_to_form(settings_page, settings_page, frappe.bold(settings_page)))) def get_link_filters(self, for_doctype): if hasattr(self, "prev_link_mapper") and self.prev_link_mapper.get(for_doctype):