From e3ec8d2975fadfcdcce84e5a7f3dd9d2115d70ee Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 22 Jul 2026 14:40:27 +0530 Subject: [PATCH] refactor: exempt system doctypes via in_create flag Doctypes marked In Create (GL Entry, Stock Ledger Entry, Bin, ledger entries) are system-created by definition, so derive their exemption from meta instead of listing them. --- .../doctype/company_restriction/company_restriction.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/erpnext/stock/doctype/company_restriction/company_restriction.py b/erpnext/stock/doctype/company_restriction/company_restriction.py index c45f4f495f9..9f19263b2a4 100644 --- a/erpnext/stock/doctype/company_restriction/company_restriction.py +++ b/erpnext/stock/doctype/company_restriction/company_restriction.py @@ -13,17 +13,12 @@ RESTRICTABLE_MASTER_DOCTYPES = ("Item", "Customer", "Supplier") COMPANY_RESTRICTION_EXEMPT_DOCTYPES = frozenset( { - "Advance Payment Ledger Entry", "Asset", "Bank Transaction", - "Bin", "Exchange Rate Revaluation", - "GL Entry", "Landed Cost Voucher", - "Loyalty Point Entry", "POS Closing Entry", "POS Invoice Merge Log", - "Payment Ledger Entry", "Payment Reconciliation", "Process Payment Reconciliation", "Repost Accounting Ledger", @@ -31,9 +26,6 @@ COMPANY_RESTRICTION_EXEMPT_DOCTYPES = frozenset( "Repost Payment Ledger", "Serial No", "Serial and Batch Bundle", - "Stock Closing Balance", - "Stock Ledger Entry", - "Stock Reservation Entry", "Unreconcile Payment", } ) @@ -136,7 +128,7 @@ def validate_allowed_companies(doc, method=None): def validate_transaction_company(doc, method=None): - if doc.doctype in COMPANY_RESTRICTION_EXEMPT_DOCTYPES: + if doc.doctype in COMPANY_RESTRICTION_EXEMPT_DOCTYPES or doc.meta.in_create: return company_field = doc.meta.get_field("company")