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.
This commit is contained in:
Mihir Kandoi
2026-07-22 14:28:13 +05:30
parent 01892c2e26
commit ce01fa0e34
2 changed files with 21 additions and 0 deletions

View File

@@ -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 = {

View File

@@ -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"
)