mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-01 11:19:09 +00:00
perf: speed up customer import (#47738)
* perf: Avoid fetching customer from DB This is likely code from bygone era where is_new and doc_before_save didn't exist? I see no reason to do it in this weird manner. This code still appears to be wrong but I'll leave it as is for now. * fix: don't validate internal customer for non-internal customer This was likely missed out while adding validations
This commit is contained in:
@@ -152,8 +152,7 @@ class Customer(TransactionBase):
|
|||||||
self.validate_currency_for_receivable_payable_and_advance_account()
|
self.validate_currency_for_receivable_payable_and_advance_account()
|
||||||
|
|
||||||
# set loyalty program tier
|
# set loyalty program tier
|
||||||
if frappe.db.exists("Customer", self.name):
|
if not self.is_new() and (customer := self.get_doc_before_save()):
|
||||||
customer = frappe.get_doc("Customer", self.name)
|
|
||||||
if self.loyalty_program == customer.loyalty_program and not self.loyalty_program_tier:
|
if self.loyalty_program == customer.loyalty_program and not self.loyalty_program_tier:
|
||||||
self.loyalty_program_tier = customer.loyalty_program_tier
|
self.loyalty_program_tier = customer.loyalty_program_tier
|
||||||
|
|
||||||
@@ -207,6 +206,7 @@ class Customer(TransactionBase):
|
|||||||
def validate_internal_customer(self):
|
def validate_internal_customer(self):
|
||||||
if not self.is_internal_customer:
|
if not self.is_internal_customer:
|
||||||
self.represents_company = ""
|
self.represents_company = ""
|
||||||
|
return
|
||||||
|
|
||||||
internal_customer = frappe.db.get_value(
|
internal_customer = frappe.db.get_value(
|
||||||
"Customer",
|
"Customer",
|
||||||
|
|||||||
Reference in New Issue
Block a user