From 737ec6b26e8c2c6f575bbe8e0fdca752d12d0548 Mon Sep 17 00:00:00 2001 From: deepeshgarg007 Date: Sun, 20 Oct 2019 17:36:36 +0530 Subject: [PATCH] fix: Travis --- erpnext/accounts/party.py | 6 ++++-- erpnext/buying/doctype/supplier/test_supplier.py | 3 ++- erpnext/exceptions.py | 1 + erpnext/selling/doctype/customer/test_customer.py | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 20f8737f54..59936d5116 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -12,7 +12,7 @@ from frappe.utils import (add_days, getdate, formatdate, date_diff, from frappe.contacts.doctype.address.address import (get_address_display, get_default_address, get_company_address) from frappe.contacts.doctype.contact.contact import get_contact_details, get_default_contact -from erpnext.exceptions import PartyFrozen, InvalidAccountCurrency +from erpnext.exceptions import PartyFrozen, PartyDisabled, InvalidAccountCurrency from erpnext.accounts.utils import get_fiscal_year from erpnext import get_company_currency @@ -446,7 +446,9 @@ def validate_party_frozen_disabled(party_type, party_name): if party_type and party_name: if party_type in ("Customer", "Supplier"): party = frappe.get_cached_value(party_type, party_name, ["is_frozen", "disabled"], as_dict=True) - if party.get("is_frozen"): + if party.disabled: + frappe.throw(_("{0} {1} is disabled").format(party_type, party_name), PartyDisabled) + elif party.get("is_frozen"): frozen_accounts_modifier = frappe.db.get_single_value( 'Accounts Settings', 'frozen_accounts_modifier') if not frozen_accounts_modifier in frappe.get_roles(): frappe.throw(_("{0} {1} is frozen").format(party_type, party_name), PartyFrozen) diff --git a/erpnext/buying/doctype/supplier/test_supplier.py b/erpnext/buying/doctype/supplier/test_supplier.py index 227a3dfee8..a377ec90f8 100644 --- a/erpnext/buying/doctype/supplier/test_supplier.py +++ b/erpnext/buying/doctype/supplier/test_supplier.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import frappe, unittest from erpnext.accounts.party import get_due_date +from erpnext.exceptions import PartyDisabled from frappe.test_runner import make_test_records test_dependencies = ['Payment Term', 'Payment Terms Template'] @@ -70,7 +71,7 @@ class TestSupplier(unittest.TestCase): po = create_purchase_order(do_not_save=True) - self.assertRaises(frappe.ValidationError, po.save) + self.assertRaises(PartyDisabled, po.save) frappe.db.set_value("Supplier", "_Test Supplier", "disabled", 0) diff --git a/erpnext/exceptions.py b/erpnext/exceptions.py index fb3a5cb55d..d92af5d722 100644 --- a/erpnext/exceptions.py +++ b/erpnext/exceptions.py @@ -5,3 +5,4 @@ import frappe class PartyFrozen(frappe.ValidationError): pass class InvalidAccountCurrency(frappe.ValidationError): pass class InvalidCurrency(frappe.ValidationError): pass +class PartyDisabled(frappe.ValidationError):pass diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 42c7d99e41..87fdaa366f 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -8,7 +8,7 @@ import unittest from erpnext.accounts.party import get_due_date from frappe.test_runner import make_test_records -from erpnext.exceptions import PartyFrozen +from erpnext.exceptions import PartyFrozen, PartyDisabled from frappe.utils import flt from erpnext.selling.doctype.customer.customer import get_credit_limit, get_customer_outstanding from erpnext.tests.utils import create_test_contact_and_address @@ -178,7 +178,7 @@ class TestCustomer(unittest.TestCase): so = make_sales_order(do_not_save=True) - self.assertRaises(frappe.ValidationError, so.save) + self.assertRaises(PartyDisabled, so.save) frappe.db.set_value("Customer", "_Test Customer", "disabled", 0)