mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-16 07:58:38 +00:00
perf: rewrite customer and supplier naming setters only on change
Every Selling Settings save reran set_by_naming_series for Customer and every Buying Settings save reran it for Supplier, rewriting the naming_series property setters with their cache clears and running the naming_series backfill UPDATE on the master table. Gate both on has_value_changed, following Stock Settings. Naming behaviour is unaffected: Customer.autoname and Supplier.autoname read the master-name default, which is still set on every save.
This commit is contained in:
@@ -53,6 +53,15 @@ class BuyingSettings(Document):
|
||||
for key in ["supplier_group", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
|
||||
frappe.db.set_default(key, self.get(key, ""))
|
||||
|
||||
self.update_supplier_naming_settings()
|
||||
|
||||
if not self.bill_for_rejected_quantity_in_purchase_invoice:
|
||||
self.set_valuation_rate_for_rejected_materials = 0
|
||||
|
||||
def update_supplier_naming_settings(self):
|
||||
if not self.has_value_changed("supp_master_name"):
|
||||
return
|
||||
|
||||
from erpnext.utilities.naming import set_by_naming_series
|
||||
|
||||
set_by_naming_series(
|
||||
@@ -62,9 +71,6 @@ class BuyingSettings(Document):
|
||||
hide_name_field=False,
|
||||
)
|
||||
|
||||
if not self.bill_for_rejected_quantity_in_purchase_invoice:
|
||||
self.set_valuation_rate_for_rejected_materials = 0
|
||||
|
||||
def before_save(self):
|
||||
self.check_maintain_same_rate()
|
||||
|
||||
|
||||
@@ -84,14 +84,7 @@ class SellingSettings(Document):
|
||||
]:
|
||||
frappe.db.set_default(key, self.get(key, ""))
|
||||
|
||||
from erpnext.utilities.naming import set_by_naming_series
|
||||
|
||||
set_by_naming_series(
|
||||
"Customer",
|
||||
"customer_name",
|
||||
self.get("cust_master_name") == "Naming Series",
|
||||
hide_name_field=False,
|
||||
)
|
||||
self.update_customer_naming_settings()
|
||||
|
||||
self.validate_fallback_to_default_price_list()
|
||||
|
||||
@@ -101,6 +94,19 @@ class SellingSettings(Document):
|
||||
if old_doc and old_doc.enable_utm != self.enable_utm:
|
||||
toggle_utm_analytics_section(not self.enable_utm)
|
||||
|
||||
def update_customer_naming_settings(self):
|
||||
if not self.has_value_changed("cust_master_name"):
|
||||
return
|
||||
|
||||
from erpnext.utilities.naming import set_by_naming_series
|
||||
|
||||
set_by_naming_series(
|
||||
"Customer",
|
||||
"customer_name",
|
||||
self.get("cust_master_name") == "Naming Series",
|
||||
hide_name_field=False,
|
||||
)
|
||||
|
||||
def validate_fallback_to_default_price_list(self):
|
||||
if (
|
||||
self.fallback_to_default_price_list
|
||||
|
||||
Reference in New Issue
Block a user