Skip to content

[16.0] [FIX] sale_commission_agent_restrict: change res_partner form view restriction to _get_view#676

Open
rrebollo wants to merge 1 commit into
OCA:16.0from
BinhexTeam:16.0-fix-sale_commission_agent_restrict-view-inheritance
Open

[16.0] [FIX] sale_commission_agent_restrict: change res_partner form view restriction to _get_view#676
rrebollo wants to merge 1 commit into
OCA:16.0from
BinhexTeam:16.0-fix-sale_commission_agent_restrict-view-inheritance

Conversation

@rrebollo
Copy link
Copy Markdown

Why this change was made

Root cause: Odoo PR #95729, merged in Odoo 16.0, unified the behavior of the groups attribute across the framework.

Before 16.0

When groups was applied to an XML node in a back-end view, the node was only made invisible — it remained in the view architecture. Third-party modules could reliably:

  • Extend the view via xpath inheritance
  • Reference those nodes as selectors
  • Rely on fields inside them for domain/context evaluation

After 16.0

The groups attribute completely removes the node from the view architecture for users outside the group — matching the long-standing behavior of groups on Python model fields. The PR description states this was done to:

  1. Make behavior uniform across Python fields, back-end XML nodes, and front-end nodes
  2. Enable view caching without requiring groups in the cache key

The problem this caused

The old XML in sale_commission_agent_restrict used:

<page name='sales_purchases' position="attributes">
    <attribute name="groups">!sale_commission_agent_restrict.group_agent_own_commissions</attribute>
</page>

In Odoo 16.0, those pages are stripped from the arch entirely for agent users. Any third-party module that references those pages (e.g., xpath="//page[@name='sales_purchases']") gets an error because the node no longer exists. Code that worked in 15.0 silently breaks in 16.0.

Why _get_view() is better
The Python override keeps the pages in the arch and sets invisible="1" at runtime. The nodes remain present for:

  • Xpath selectors — inheritance from other modules won't break
  • Domain evaluation — fields inside the pages remain accessible
  • View inheritance — third-party modules can still add content relative to these pages

This is both safer (no breaking changes for dependant modules) and more reliable (explicit control over visibility logic).

One commit cherry-picked from #675

@BinhexTeam T21484

@OCA-git-bot
Copy link
Copy Markdown
Contributor

Hi @aleuffre,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added mod:sale_commission_agent_restrict Module sale_commission_agent_restrict series:16.0 labels May 13, 2026
@rrebollo rrebollo force-pushed the 16.0-fix-sale_commission_agent_restrict-view-inheritance branch from 4165380 to d8e3a91 Compare May 15, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:sale_commission_agent_restrict Module sale_commission_agent_restrict series:16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants