diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 3011fd68c7..8181febd58 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -11,8 +11,7 @@ from frappe.utils import add_days, getdate, formatdate, get_first_day, date_diff from erpnext.utilities.doctype.address.address import get_address_display from erpnext.utilities.doctype.contact.contact import get_contact_details -class InvalidCurrency(frappe.ValidationError): pass -class InvalidAccountCurrency(frappe.ValidationError): pass +class DuplicatePartyAccountError(frappe.ValidationError): pass @frappe.whitelist() def get_party_details(party=None, account=None, party_type="Customer", company=None, @@ -197,7 +196,8 @@ def validate_party_accounts(doc): for account in doc.get("accounts"): if account.company in companies: - frappe.throw(_("There can only be 1 Account per Company in {0} {1}").format(doc.doctype, doc.name)) + frappe.throw(_("There can only be 1 Account per Company in {0} {1}").format(doc.doctype, doc.name), + DuplicatePartyAccountError) else: companies.append(account.company) diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index a0a1501a46..4bd02d5112 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -8,8 +8,6 @@ import unittest from frappe.test_runner import make_test_records from erpnext.controllers.accounts_controller import CustomerFrozen -from erpnext.accounts.party import InvalidCurrency -from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice test_ignore = ["Price List"] @@ -37,9 +35,9 @@ class TestCustomer(unittest.TestCase): make_test_records("Address") make_test_records("Contact") - frappe.db.set_value("Contact", "_Test Contact For _Test Customer-_Test Customer", + frappe.db.set_value("Contact", "_Test Contact For _Test Customer-_Test Customer", "is_primary_contact", 1) - + details = get_party_details("_Test Customer") for key, value in to_check.iteritems(): @@ -68,25 +66,15 @@ class TestCustomer(unittest.TestCase): {"comment_doctype": "Customer", "comment_docname": "_Test Customer 1 Renamed"}), comment.name) frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1") - + def test_freezed_customer(self): frappe.db.set_value("Customer", "_Test Customer", "is_frozen", 1) - + from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order - + so = make_sales_order(do_not_save= True) self.assertRaises(CustomerFrozen, so.save) - + frappe.db.set_value("Customer", "_Test Customer", "is_frozen", 0) - + so.save() - - def test_multi_currency(self): - customer = frappe.get_doc("Customer", "_Test Customer USD") - - create_sales_invoice(customer="_Test Customer USD", debit_to="_Test Receivable USD - _TC", - currency="USD", conversion_rate=50) - - customer.party_account_currency = "EUR" - self.assertRaises(InvalidCurrency, customer.save) - \ No newline at end of file