A user with Read permission on Purchase Invoice opens the list and sees "No Purchase Invoice found." Purchase Order works. Sales Invoice works. Delivery Note works. Only Purchase Invoice is empty, and ERPNext shows no error, no warning, and no hint that a filter was applied. The cause is Apply Strict User Permissions in System Settings combined with a Company User Permission left on its default "Apply to All Document Types": the permission engine ANDs a condition onto represents_company, a field that is NULL on every invoice from an ordinary external supplier. ERPNext closed this in issue #57072 with PR #57073: a single JSON flag on one field, shipped in v15.116.0 and v16.27.0. That is the part worth pausing on. Because the fix was a per-field flag, not a change to the permission engine, the same bug is still live on Asset and on Shipment, and upgrading does not fix either (checked on the version-15 and version-16 branches on 12 October 2026).
I lead ERPNext and Frappe programmes at MithTech, a team of Frappe specialists in Bengaluru. We enable Strict User Permissions on most of the ERPNext implementations we run for multi-company groups, because the alternative, blank link fields quietly counting as "allowed", is not something an auditor accepts. That makes this kind of bug our problem, which is why we audited every doctype in the codebase instead of stopping at the one that got patched.
What happens in the query?
The permission engine builds list-view filters in DatabaseQuery.add_user_permissions(), in frappe/model/db_query.py. Three properties of that function combine into the bug, and all three are working as designed:
- It iterates every Link field on the doctype, via
self.doctype_meta.get_link_fields(), not only the field you think of as the scoping one. A User Permission on Company with Apply to All Document Types populatesuser_permissions["Company"], so every Link-to-Company field on the doctype produces a condition. - It joins those conditions with AND. Every non-exempt Link-to-Company field must match. There is no "at least one" mode.
- Strict mode deletes the escape hatch. With strict off, each condition is prefixed with
ifnull(field, '') = '' or, so a blank field passes. With strict on, that part is not emitted.
Only ignore_user_permissions on the field itself makes the loop skip a field. That single flag is the whole surface area of the fix.
This post is part of the Frappe and ERPNext Architecture Guide. Its permissions chapter explains why a list is filtered with conditions, not checked one document at a time.
Interactive
Match Condition Visualiser
Toggle Apply Strict User Permissions and Apply to All Document Types and watch the WHERE clause ERPNext generates for a pre-fix Purchase Invoice list. The ifnull escape appears and disappears in real time, and the verdict panel says whether the user sees rows or an empty list.
With strict on and a permission of Allow = Company, For Value = 'XYZ Ltd', Apply to All Document Types = 1, the list query gets:
((
(`tabPurchase Invoice`.`company` in ('XYZ Ltd'))
and
(`tabPurchase Invoice`.`represents_company` in ('XYZ Ltd'))
))
represents_company is NULL on every purchase invoice from an ordinary external supplier, and NULL in ('XYZ Ltd') is never true. Zero rows. The form view is slightly more honest: open a specific invoice by URL and has_user_permission() produces "You are not allowed to access this Purchase Invoice record because it is linked to Company 'empty' in field Represents Company." That message is the only place the system tells you what happened, and nobody reaches it, because the list view gave them nothing to click.
Why is represents_company blank?
represents_company exists for inter-company transactions: when one company in your group buys from or sells to another company in the same instance. On the Supplier master it is gated behind is_internal_supplier, and Supplier's copy already carried ignore_user_permissions: 1. On Purchase Invoice it is a fetched mirror ("fetch_from": "supplier.represents_company"), typed in Python as DF.Link | None.
So for every ordinary external supplier the field is legitimately NULL, and in a typical install nearly all purchase invoices have it blank. It is an identity field, not a scoping field. The scoping field is company. That distinction is what ignore_user_permissions is for, which is why the small fix is correct and not a hack, and why the accompanying "read_only": 1 makes sense for a value nobody should type by hand.
Why doesn't the fix cover other doctypes?
Because the maintainers chose a per-field flag over a framework change, the correctness of the whole system now depends on every doctype having the flag set correctly on every optional link. So we checked. We pulled the full ERPNext v15.116.0 source tarball, parsed all 659 non-child DocType JSON files, and listed every doctype with more than one Link → Company field along with each field's ignore_user_permissions value. Then we re-checked the interesting ones against v15.119.0, the latest release when this was written, and again on the version-15 and version-16 branches on 12 October 2026.
Eleven doctypes have more than one Link to Company. Nine are fine. Two are not.
Interactive
Field Exposure Auditor
Every ERPNext doctype carrying more than one Link-to-Company field, with each field's ignore_user_permissions flag, whether it is usually populated on a real record, the match condition strict mode generates, and a verdict on whether the list view survives.
Asset. asset_owner_company is still ignore_user_permissions: 0. It only appears when asset_owner == "Company", so for any asset owned by a supplier or customer — third-party, leased, consignment — it is NULL. In strict mode with an Apply-to-All Company permission, those assets vanish from the Asset list exactly the way purchase invoices did. This is not speculation: the reporter of #57072 hit it in production and said so in the thread on 2026-05-06, and the comment that proposed the ignore_user_permissions approach explicitly named asset_owner_company alongside represents_company. Only the Purchase Invoice half shipped. As of 12 October 2026 there is no released fix.
Shipment. pickup_company and delivery_company are both conditional (pickup_from_type == 'Company' and delivery_to_type == 'Company') and both ignore_user_permissions: 0. On a normal outbound shipment delivery_company is blank; on an inbound one pickup_company is blank. The engine's behaviour is verified and the field metadata is verified, so the Shipment list should go empty for restricted users in both directions.
The generalisable rule is the real takeaway, and it is not about Company at all: Strict User Permissions with Apply to All Document Types is only safe on a doctype where every non-exempt Link field pointing at the restricted doctype is always populated. Any optional or conditional second link to the same target ANDs the list to zero without a word. Warehouse, Cost Center, Project, Territory and Branch fail the same way wherever a doctype carries two links to them.
There is precedent for this being handled one field at a time rather than structurally: v15.116.0 and v16.27.0 also shipped "ignore user permissions for link fields having link to Account and Cost Center" on the Company doctype. Same problem, different link target, separate patch.
How do you diagnose, fix and verify it?
Code recipe
Diagnose / Fix / Verify Recipe
Three copyable tabs: a bench console script that lists every at-risk doctype on your instance, three fix routes including the Property Setter that reproduces the upstream patch, and a verification script that prints the actual match condition the permission engine generates for a restricted user.
0 of 6 steps done
Tick a step’s number when it is done; the ticks stay on this device.
Isolate it with the strict toggle
As Administrator, untick Apply Strict User Permissions in System Settings and reload the Purchase Invoice list as the restricted user. If it fills up, you have confirmed the cause. Re-tick it: you are not done, and leaving it off is the one "fix" that quietly throws away the control you wanted.
Read the match condition, do not guess it
Run the Verify tab. DatabaseQuery("Purchase Invoice").build_match_conditions() executed as the restricted user prints the exact WHERE fragment. Two ANDed clauses means you are on a pre-fix build; one clause on company alone means the flag is in place. This beats looking at a list, because an empty list has several possible causes and only one of them is this bug.
Apply the flag through Customize Form
Customize Form → Enter Form Type = Purchase Invoice → expand the represents_company row → tick Ignore User Permissions → Update. No restart, no code. It writes a Property Setter, so it survives bench migrate, and it has the same permission effect as the upstream patch (which also made the field read-only).
Run the audit before you trust the upgrade
The Diagnose tab enumerates every doctype on your instance with more than one non-exempt Link to Company, including any custom doctypes and any custom fields you have added. Custom fields matter here: a Link-to-Company custom field on a transactional doctype reproduces this bug on a fully patched ERPNext.
Decide on Asset and Shipment deliberately
If you use Assets with third-party owners, or Shipments in either direction, apply the same Property Setter to asset_owner_company, pickup_company and delivery_company — or accept that those lists are filtered to zero for restricted users. Don't leave it undecided, because the failure is silent and nobody will report it as a bug.
Upgrade, then re-verify
Move to v15.116.0+ or v16.27.0+ on a schedule, in staging first. Your Property Setters remain afterwards: redundant on Purchase Invoice, still doing the work on Asset and Shipment. Delete the redundant one when you next clean up your customisation inventory.
How do you choose between the four options?
| Option | Effort | What it covers | Main risk |
|---|---|---|---|
| Ignore User Permissions via Customize Form | Minutes, no downtime | Exactly the fields you flag, including Asset and Shipment | Creates a Property Setter you must remember you own |
| Untick Apply to All, scope per-doctype | One User Permission row per doctype per user | Every doctype you remember to add | Fail-open: a doctype you forget is unrestricted and nobody is told |
| Upgrade to v15.116.0 / v16.27.0 | Full regression cycle in staging | Purchase Invoice only | Does not touch Asset or Shipment; easy to assume it did |
| Turn Strict User Permissions off | One click | Every list, instantly | Discards the isolation you enabled strict mode to get |
A fifth suggestion appears in the issue thread and is worth heading off: a custom permission_query_conditions hook. It looks like a fix and is not one. Conditions returned by that hook are ANDed onto the user-permission match conditions, so a hook can only narrow the result set, never widen it. It cannot rescue an empty list on its own.
What is on the readiness checklist?
Interactive
Strict Permissions Readiness Checklist
Eight items to settle before enabling Apply Strict User Permissions on a multi-company instance — version, doctype audit, the Asset and Shipment decisions, and testing as a genuinely restricted user.
At a glance
| Answer | |
|---|---|
| Symptom | Empty Purchase Invoice list for a restricted user, no error |
| Cause | Apply Strict User Permissions + Company User Permission on Apply to All Document Types |
| Field at fault | represents_company, blank on invoices from external suppliers |
| Fixed in | ERPNext v15.116.0 and v16.27.0 (PR #57073) |
| Still affected (12 Oct 2026) | Asset.asset_owner_company; Shipment.pickup_company and delivery_company (inference) |
| Fix without upgrading | Customize Form → tick Ignore User Permissions on the identity field, never on company |
Frequently asked questions
Why can't my user see any Purchase Invoices in ERPNext even though they have read permission?
Almost certainly Apply Strict User Permissions combined with a Company User Permission left on Apply to All Document Types. The permission engine ANDs a condition on represents_company, which is NULL on every invoice from an ordinary external supplier, so the list resolves to zero rows with no error. Test it quickly: untick Apply Strict User Permissions in System Settings. If the list fills up, that is your cause.
What does Apply Strict User Permissions actually do in ERPNext System Settings?
It removes the "blank counts as allowed" escape. Normally each restricted link field is checked as ifnull(field,'')='' OR field IN (allowed values). With strict mode on, the ifnull half is not emitted, so a document with a blank restricted link field is hidden rather than shown. That is the documented behaviour. The bug was never that strict mode misbehaved; it was that ERPNext shipped a doctype with a Link-to-Company field blank on nearly every real record.
Which ERPNext version fixes the Purchase Invoice not visible with Company user permission bug?
ERPNext v15.116.0 on the version-15 line and v16.27.0 on the version-16 line, both released on 13 July 2026. The fix is issue #57072, PR #57073, with backports #57074 and #57075. If you are on v15.115.0 or earlier, or v16.26.x or earlier, you still have it. These releases fix Purchase Invoice only; Asset and Shipment carry the same pattern and are not covered.
Why are my ERPNext purchase invoices not showing up for a user?
Because a Company user permission set to apply to all document types is also being matched against the Represents Company field, which is empty on ordinary invoices, and strict user permissions removes the rule that lets empty fields pass. Fix it by ticking Ignore User Permissions on the Represents Company field in Customize Form, or by upgrading to ERPNext 15.116 or 16.27.
How do I set ignore user permissions on a field in ERPNext without touching code?
Open Customize Form, set Enter Form Type to the doctype, expand the field's row in the Fields table, tick Ignore User Permissions, and click Update. It writes a Property Setter, so it survives bench migrate. Apply it to identity fields like represents_company or asset_owner_company, never to the company field itself, which is the field enforcing your isolation.
What is Represents Company on a Purchase Invoice in ERPNext and why is it blank?
It identifies which sister company a counterparty represents in inter-company transactions, so ERPNext can pair a Purchase Invoice in one company with the corresponding Sales Invoice in another. It fetches from supplier.represents_company, which only exists when the Supplier is flagged Is Internal Supplier. For every ordinary external supplier it is legitimately NULL, and since the fix it is read-only as well.
What happens if we don't fix this and leave strict user permissions on?
Restricted users keep seeing an empty Purchase Invoice list with no error on unpatched versions, and on any version they keep seeing empty Asset and Shipment lists too. Nothing logs it. People work around it by raising roles or asking a System Manager to pull the data, which wears down the isolation you enabled strict mode to enforce. The failure is silent, so the cost shows up as workarounds, not as a ticket.
Is it safe to turn on strict user permissions in ERPNext?
Only after you check your doctypes. Strict mode needs every link field pointing at the restricted record to be filled in. Assets with a blank asset owner company, and shipments with a blank pickup or delivery company, disappear from list views the same way purchase invoices did, and unlike the Purchase Invoice bug, those two are still unfixed as of 12 October 2026.
One last point: an empty list is not always a permission problem. If your accounts team sees a Purchase Invoice list that looks wrong rather than empty, the cause is more often reconciliation state than row-level security; see the payment reconciliation automation guide for that side of it. And if a report, not a list, shows too much, read why ERPNext reports can ignore User Permissions. Rule out strict mode first, because it is the one cause that produces zero rows and zero explanation.
The Purchase Invoice half of this is closed, and if you are on a current release you already have it. The part that is not closed is the assumption under it: that a permission model enforced by per-field flags stays correct as doctypes and custom fields accumulate. Asset and Shipment are the two live counter-examples in the standard app today, and the next one will be a Link-to-Company custom field somebody adds to a transactional doctype on your own instance. Audit before you tick the box, not after someone reports an empty list.
Comments & ratings
No comments yet. Start a new discussion.
Manoj · Published on 5 August 2026
Worked with us? Leave a Google review