From ce01fa0e34e7c915174afa73be678fc77530d2e4 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 22 Jul 2026 14:28:13 +0530 Subject: [PATCH] fix: cover manufacturing, logistics, asset and service doctypes Extend company restriction enforcement to the remaining user-entered transactions (BOM, Work Order, Job Card, Production Plan, Pick List, Blanket Order, asset and maintenance documents). Ledger and repost doctypes stay excluded so cancelling or reposting older documents keeps working after a restriction changes. --- erpnext/hooks.py | 13 +++++++++++++ .../company_restriction/test_company_restriction.py | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 54ab7f03ea0..73b72334b55 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -382,6 +382,19 @@ company_restricted_transaction_doctypes = [ "Journal Entry", "Subcontracting Order", "Subcontracting Receipt", + "BOM", + "Work Order", + "Job Card", + "Production Plan", + "Pick List", + "Blanket Order", + "Asset Capitalization", + "Asset Repair", + "Dunning", + "Installation Note", + "Maintenance Schedule", + "Maintenance Visit", + "Warranty Claim", ] doc_events = { diff --git a/erpnext/stock/doctype/company_restriction/test_company_restriction.py b/erpnext/stock/doctype/company_restriction/test_company_restriction.py index d33f5791830..811ce58bb40 100644 --- a/erpnext/stock/doctype/company_restriction/test_company_restriction.py +++ b/erpnext/stock/doctype/company_restriction/test_company_restriction.py @@ -59,3 +59,11 @@ class TestCompanyRestriction(ERPNextTestSuite): item = make_item() item.restrict_to_companies = 1 self.assertRaises(frappe.MandatoryError, item.save) + + def test_hooked_doctypes_have_company_field(self): + from erpnext.hooks import company_restricted_transaction_doctypes + + for doctype in company_restricted_transaction_doctypes: + self.assertTrue( + frappe.get_meta(doctype).has_field("company"), f"{doctype} has no company field" + )