fix: Ignore missing customer group while fetching price list
This commit is contained in:
parent
e874149b94
commit
9ace7d606c
@ -151,7 +151,7 @@ def set_contact_details(party_details, party, party_type):
|
|||||||
|
|
||||||
def set_other_values(party_details, party, party_type):
|
def set_other_values(party_details, party, party_type):
|
||||||
# copy
|
# copy
|
||||||
if party_type=="Customer":
|
if party_type == "Customer":
|
||||||
to_copy = ["customer_name", "customer_group", "territory", "language"]
|
to_copy = ["customer_name", "customer_group", "territory", "language"]
|
||||||
else:
|
else:
|
||||||
to_copy = ["supplier_name", "supplier_group", "language"]
|
to_copy = ["supplier_name", "supplier_group", "language"]
|
||||||
@ -170,12 +170,11 @@ def get_default_price_list(party):
|
|||||||
return party.default_price_list
|
return party.default_price_list
|
||||||
|
|
||||||
if party.doctype == "Customer":
|
if party.doctype == "Customer":
|
||||||
price_list = frappe.get_cached_value("Customer Group",
|
try:
|
||||||
party.customer_group, "default_price_list")
|
return frappe.get_cached_value("Customer Group", party.customer_group, "default_price_list")
|
||||||
if price_list:
|
except frappe.exceptions.DoesNotExistError:
|
||||||
return price_list
|
return
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
def set_price_list(party_details, party, party_type, given_price_list, pos=None):
|
def set_price_list(party_details, party, party_type, given_price_list, pos=None):
|
||||||
# price list
|
# price list
|
||||||
|
16
erpnext/accounts/test_party.py
Normal file
16
erpnext/accounts/test_party.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import frappe
|
||||||
|
from frappe.tests.utils import FrappeTestCase
|
||||||
|
|
||||||
|
from erpnext.accounts.party import get_default_price_list
|
||||||
|
|
||||||
|
|
||||||
|
class PartyTestCase(FrappeTestCase):
|
||||||
|
def test_get_default_price_list_should_return_none_for_invalid_group(self):
|
||||||
|
customer = frappe.get_doc({
|
||||||
|
'doctype': 'Customer',
|
||||||
|
'customer_name': 'test customer',
|
||||||
|
}).insert(ignore_permissions=True, ignore_mandatory=True)
|
||||||
|
customer.customer_group = None
|
||||||
|
customer.save()
|
||||||
|
price_list = get_default_price_list(customer)
|
||||||
|
assert price_list is None
|
Loading…
x
Reference in New Issue
Block a user