diff --git a/erpnext/setup/doctype/currency_exchange/currency_exchange.py b/erpnext/setup/doctype/currency_exchange/currency_exchange.py index 60d367a4bb..6480f60f59 100644 --- a/erpnext/setup/doctype/currency_exchange/currency_exchange.py +++ b/erpnext/setup/doctype/currency_exchange/currency_exchange.py @@ -14,10 +14,14 @@ class CurrencyExchange(Document): purpose = "" if not self.date: self.date = nowdate() + + # If both selling and buying enabled + purpose = "Selling-Buying" if cint(self.for_buying)==0 and cint(self.for_selling)==1: purpose = "Selling" if cint(self.for_buying)==1 and cint(self.for_selling)==0: purpose = "Buying" + self.name = '{0}-{1}-{2}{3}'.format(formatdate(get_datetime_str(self.date), "yyyy-MM-dd"), self.from_currency, self.to_currency, ("-" + purpose) if purpose else "") diff --git a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py index 857f666b2a..c5c01c5775 100644 --- a/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py +++ b/erpnext/setup/doctype/currency_exchange/test_currency_exchange.py @@ -11,7 +11,9 @@ test_records = frappe.get_test_records('Currency Exchange') def save_new_records(test_records): for record in test_records: - purpose = str("") + # If both selling and buying enabled + purpose = "Selling-Buying" + if cint(record.get("for_buying"))==0 and cint(record.get("for_selling"))==1: purpose = "Selling" if cint(record.get("for_buying"))==1 and cint(record.get("for_selling"))==0: