diff --git a/public/js/transaction.js b/public/js/transaction.js index d52b742228..664bbe2f9e 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -499,16 +499,16 @@ 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); + wn.throw(wn._('%(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 + }); } }, 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