From 151864079bc1cede50da0ee2a5d101ad57647ea7 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Tue, 14 Apr 2026 10:18:39 +0530 Subject: [PATCH] refactor: move allowed doctypes to accounts settings - dropped 'allowed' field (cherry picked from commit d5c58277cb8dc585c6cd1ff9b78982456d72d261) --- .../accounts_settings/accounts_settings.py | 24 +++++++++++++++++++ .../repost_allowed_types.json | 21 ++++------------ .../repost_allowed_types.py | 1 - erpnext/patches.txt | 1 + ...ge_repost_settings_to_accounts_settings.py | 10 ++++++++ 5 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 erpnext/patches/v16_0/merge_repost_settings_to_accounts_settings.py diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py index 279d7f8e627..693d0918d20 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py @@ -10,6 +10,9 @@ from frappe.custom.doctype.property_setter.property_setter import make_property_ from frappe.model.document import Document from frappe.utils import cint +from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import ( + get_accounting_dimensions, +) from erpnext.accounts.utils import sync_auto_reconcile_config SELLING_DOCTYPES = [ @@ -143,6 +146,7 @@ class AccountsSettings(Document): frappe.clear_cache() self.validate_and_sync_auto_reconcile_config() + self.update_property_for_accounting_dimension() def validate_stale_days(self): if not self.allow_stale and cint(self.stale_days) <= 0: @@ -189,6 +193,17 @@ class AccountsSettings(Document): title=_("Auto Tax Settings Error"), ) + def update_property_for_accounting_dimension(self): + doctypes = [entry.document_type for entry in self.repost_allowed_types] + if not doctypes: + return + + from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger import get_child_docs + + doctypes += get_child_docs(doctypes) + + set_allow_on_submit_for_dimension_fields(doctypes) + @frappe.whitelist() def drop_ar_sql_procedures(self): from erpnext.accounts.report.accounts_receivable.accounts_receivable import InitSQLProceduresForAR @@ -228,3 +243,12 @@ def create_property_setter_for_hiding_field(doctype, field_name, hide): "Check", validate_fields_for_doctype=False, ) + + +def set_allow_on_submit_for_dimension_fields(doctypes): + for dt in doctypes: + meta = frappe.get_meta(dt) + for dimension in get_accounting_dimensions(): + df = meta.get_field(dimension) + if df and not df.allow_on_submit: + frappe.db.set_value("Custom Field", dt + "-" + dimension, "allow_on_submit", 1) diff --git a/erpnext/accounts/doctype/repost_allowed_types/repost_allowed_types.json b/erpnext/accounts/doctype/repost_allowed_types/repost_allowed_types.json index cb7e6bac5f8..e9206b3cf2e 100644 --- a/erpnext/accounts/doctype/repost_allowed_types/repost_allowed_types.json +++ b/erpnext/accounts/doctype/repost_allowed_types/repost_allowed_types.json @@ -6,9 +6,7 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "document_type", - "column_break_sfzb", - "allowed" + "document_type" ], "fields": [ { @@ -17,29 +15,20 @@ "in_list_view": 1, "label": "Doctype", "options": "DocType" - }, - { - "default": "0", - "fieldname": "allowed", - "fieldtype": "Check", - "in_list_view": 1, - "label": "Allowed" - }, - { - "fieldname": "column_break_sfzb", - "fieldtype": "Column Break" } ], + "grid_page_length": 50, "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-03-27 13:10:32.415806", + "modified": "2026-04-14 16:53:16.806714", "modified_by": "Administrator", "module": "Accounts", "name": "Repost Allowed Types", "owner": "Administrator", "permissions": [], + "row_format": "Dynamic", "sort_field": "creation", "sort_order": "DESC", "states": [] -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/repost_allowed_types/repost_allowed_types.py b/erpnext/accounts/doctype/repost_allowed_types/repost_allowed_types.py index 8226a910171..7f0064cc3cf 100644 --- a/erpnext/accounts/doctype/repost_allowed_types/repost_allowed_types.py +++ b/erpnext/accounts/doctype/repost_allowed_types/repost_allowed_types.py @@ -14,7 +14,6 @@ class RepostAllowedTypes(Document): if TYPE_CHECKING: from frappe.types import DF - allowed: DF.Check document_type: DF.Link | None parent: DF.Data parentfield: DF.Data diff --git a/erpnext/patches.txt b/erpnext/patches.txt index a6651be8483..61b93b292b1 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -475,3 +475,4 @@ erpnext.patches.v16_0.remove_payables_receivables_workspace erpnext.patches.v16_0.co_by_product_patch erpnext.patches.v16_0.depends_on_inv_dimensions erpnext.patches.v16_0.uom_category +erpnext.patches.v16_0.merge_repost_settings_to_accounts_settings diff --git a/erpnext/patches/v16_0/merge_repost_settings_to_accounts_settings.py b/erpnext/patches/v16_0/merge_repost_settings_to_accounts_settings.py new file mode 100644 index 00000000000..55560e0c578 --- /dev/null +++ b/erpnext/patches/v16_0/merge_repost_settings_to_accounts_settings.py @@ -0,0 +1,10 @@ +import frappe + + +def execute(): + if allowed := frappe.get_hooks("repost_allowed_doctypes"): + accounts_settings = frappe.get_doc("Accounts Settings") + for x in allowed: + if x not in [t.document_type for t in accounts_settings.repost_allowed_types]: + accounts_settings.append("repost_allowed_types", {"document_type": x}) + accounts_settings.save()