From 136e00d5136fd3b609279f9d1de60ff387648d89 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 11 Aug 2026 16:21:21 +0530 Subject: [PATCH] perf: rewrite selling settings toggle setters only on change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit on_update reran toggle_hide_tax_id, toggle_editable_rate_for_bundle_items and toggle_discount_accounting_fields on every save, rewriting 11 property setters and clearing the meta cache of five doctypes. Gate each toggle on has_value_changed. Fresh installs save the settings with pure defaults (set_single_defaults), so the gated-off state must match the JSON schema: align sales_invoice.json and sales_invoice_item.json with the values every saved site already has — tax_id printed when hide_tax_id is off, discount accounts hidden while discount accounting is disabled. Packed Item rate already matches. --- .../accounts/doctype/sales_invoice/sales_invoice.json | 4 ++-- .../doctype/sales_invoice_item/sales_invoice_item.json | 3 ++- .../selling/doctype/selling_settings/selling_settings.py | 9 +++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index a2c79e63eb4..526e3aabc18 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -297,7 +297,6 @@ "hide_days": 1, "hide_seconds": 1, "label": "Tax Id", - "print_hide": 1, "read_only": 1 }, { @@ -1940,6 +1939,7 @@ "allow_on_submit": 1, "fieldname": "additional_discount_account", "fieldtype": "Link", + "hidden": 1, "label": "Discount Account", "options": "Account" }, @@ -2360,7 +2360,7 @@ "link_fieldname": "consolidated_invoice" } ], - "modified": "2026-06-21 12:46:13.250145", + "modified": "2026-08-11 12:00:00.000000", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index a046b6c4e80..8cbd6a3a5bd 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -887,6 +887,7 @@ "allow_on_submit": 1, "fieldname": "discount_account", "fieldtype": "Link", + "hidden": 1, "label": "Discount Account", "options": "Account" }, @@ -1067,7 +1068,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2026-08-07 17:31:31.732720", + "modified": "2026-08-11 12:00:00.000000", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.py b/erpnext/selling/doctype/selling_settings/selling_settings.py index 70c57579cb2..3ad49c8c9ca 100644 --- a/erpnext/selling/doctype/selling_settings/selling_settings.py +++ b/erpnext/selling/doctype/selling_settings/selling_settings.py @@ -125,6 +125,9 @@ class SellingSettings(Document): ) def toggle_hide_tax_id(self): + if not self.has_value_changed("hide_tax_id"): + return + _hide_tax_id = cint(self.hide_tax_id) # Make property setters to hide tax_id fields @@ -137,6 +140,9 @@ class SellingSettings(Document): ) def toggle_editable_rate_for_bundle_items(self): + if not self.has_value_changed("editable_bundle_item_rates"): + return + editable_bundle_item_rates = cint(self.editable_bundle_item_rates) make_property_setter( @@ -149,6 +155,9 @@ class SellingSettings(Document): ) def toggle_discount_accounting_fields(self): + if not self.has_value_changed("enable_discount_accounting"): + return + enable_discount_accounting = cint(self.enable_discount_accounting) make_property_setter(