refactor(patch): make Tax Articles grid-column injection additive

Insert custom_tax_articles_display into saved layouts independently instead of
replacing the legacy tax_article column (which is still used by other flows).
Position it after item_tax_template; leave legacy untouched. Idempotent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ali 2026-06-03 14:30:48 +00:00
parent 9c4e075527
commit 6f0758d90b
1 changed files with 6 additions and 6 deletions

View File

@ -12,9 +12,9 @@ def execute():
ignores the new in_list_view field, so the "Tax Articles" cell never appears for ignores the new in_list_view field, so the "Tax Articles" cell never appears for
those users until they add it manually via the grid gear. those users until they add it manually via the grid gear.
Replace the legacy `tax_article` entry (or, lacking it, insert after Add `custom_tax_articles_display` to every saved layout that doesn't already have
`item_tax_template`) with `custom_tax_articles_display` in every saved layout that it, positioned near the tax fields. This is purely additive: the legacy
doesn't already have it. Idempotent. `tax_article` column (if present) is left untouched. Idempotent.
""" """
rows = frappe.db.sql( rows = frappe.db.sql(
"select user, data from `__UserSettings` where doctype = 'Sales Invoice'", "select user, data from `__UserSettings` where doctype = 'Sales Invoice'",
@ -36,10 +36,10 @@ def execute():
continue continue
new_col = {"fieldname": "custom_tax_articles_display", "columns": 2} new_col = {"fieldname": "custom_tax_articles_display", "columns": 2}
if "tax_article" in names: if "item_tax_template" in names:
cols[names.index("tax_article")] = new_col
elif "item_tax_template" in names:
cols.insert(names.index("item_tax_template") + 1, new_col) cols.insert(names.index("item_tax_template") + 1, new_col)
elif "tax_article" in names:
cols.insert(names.index("tax_article") + 1, new_col)
else: else:
cols.append(new_col) cols.append(new_col)