Skip to content

Commit

Permalink
fix: demo data setup w/o territory (#36798)
Browse files Browse the repository at this point in the history
This can fail because it's translated.
  • Loading branch information
ankush authored Aug 24, 2023
1 parent 49be119 commit ab6e600
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 8 additions & 0 deletions erpnext/selling/doctype/customer/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from frappe.model.naming import set_name_by_naming_series, set_name_from_naming_options
from frappe.model.utils.rename_doc import update_linked_doctypes
from frappe.utils import cint, cstr, flt, get_formatted_email, today
from frappe.utils.nestedset import get_root_of
from frappe.utils.user import get_users_with_role

from erpnext.accounts.party import ( # noqa
Expand Down Expand Up @@ -80,6 +81,7 @@ def validate(self):
validate_party_accounts(self)
self.validate_credit_limit_on_change()
self.set_loyalty_program()
self.set_territory_and_group()
self.check_customer_group_change()
self.validate_default_bank_account()
self.validate_internal_customer()
Expand Down Expand Up @@ -138,6 +140,12 @@ def validate_default_bank_account(self):
_("{0} is not a company bank account").format(frappe.bold(self.default_bank_account))
)

def set_territory_and_group(self):
if not self.territory:
self.territory = get_root_of("Territory")
if not self.customer_group:
self.customer_group = get_root_of("Customer Group")

def validate_internal_customer(self):
if not self.is_internal_customer:
self.represents_company = ""
Expand Down
5 changes: 1 addition & 4 deletions erpnext/setup/demo_data/customer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@
{
"doctype": "Customer",
"customer_group": "Demo Customer Group",
"territory": "All Territories",
"customer_name": "Grant Plastics Ltd."
},
{
"doctype": "Customer",
"customer_group": "Demo Customer Group",
"territory": "All Territories",
"customer_name": "West View Software Ltd."
},
{
"doctype": "Customer",
"customer_group": "Demo Customer Group",
"territory": "All Territories",
"customer_name": "Palmer Productions Ltd."
}
]
]

0 comments on commit ab6e600

Please sign in to comment.