From e0b32824ff0e8313d0a15896b2145d0ba14268f5 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 12 Nov 2013 19:27:16 +0530 Subject: [PATCH] [fix] [minor] updated message for conversion rate --- public/js/transaction.js | 16 +++++++++------- utilities/transaction_base.py | 14 +++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/public/js/transaction.js b/public/js/transaction.js index d52b742228..4b941e33b1 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -499,16 +499,18 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.frm.doc.conversion_rate = flt(this.frm.doc.conversion_rate, precision("conversion_rate")); var conversion_rate_label = wn.meta.get_label(this.frm.doc.doctype, "conversion_rate", this.frm.doc.name); - - if(this.frm.doc.conversion_rate == 0) { - wn.throw(wn._(conversion_rate_label) + " " + wn._("cannot be 0")); - } - var company_currency = this.get_company_currency(); if(!this.frm.doc.conversion_rate) { - wn.throw(wn._("Please enter valid") + " " + wn._(conversion_rate_label) + - " 1 " + this.frm.doc.currency + " = [?] " + company_currency); + var msg = $(repl('%(conversion_rate_label)s is mandatory. Maybe Currency Exchange \ + record is not created for %(from_currency)s to %(to_currency)s', + { + "conversion_rate_label": conversion_rate_label, + "from_currency": self.doc.currency, + "to_currency": company_currency + })); + + wn.throw(wn._(msg)); } }, diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index 0f4d6bcacd..684da46795 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -426,15 +426,15 @@ def get_address_territory(address_doc): def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company): """common validation for currency and price list currency""" - if conversion_rate == 0: - msgprint(conversion_rate_label + _(' cannot be 0'), raise_exception=True) - company_currency = webnotes.conn.get_value("Company", company, "default_currency") - + if not conversion_rate: - msgprint(_('Please enter valid ') + conversion_rate_label + (': ') - + ("1 %s = [?] %s" % (currency, company_currency)), - raise_exception=True) + msgprint(_('%(conversion_rate_label)s is mandatory. Maybe Currency Exchange \ + record is not created for %(from_currency)s to %(to_currency)s') % { + "conversion_rate_label": conversion_rate_label, + "from_currency": currency, + "to_currency": company_currency + }, raise_exception=True) def validate_item_fetch(args, item): from stock.utils import validate_end_of_life