Skip to content

[16.0][FIX] pms: keep pms_property_ids available when restricting it by group - #441

Merged
OCA-git-bot merged 2 commits into
OCA:16.0from
commitsun:16.0-fix-pms-property-groups-view-validation
Aug 24, 2026
Merged

[16.0][FIX] pms: keep pms_property_ids available when restricting it by group#441
OCA-git-bot merged 2 commits into
OCA:16.0from
commitsun:16.0-fix-pms-property-groups-view-validation

Conversation

@DarioLodeiros

@DarioLodeiros DarioLodeiros commented Aug 24, 2026

Copy link
Copy Markdown
Member

Regression from #440.

Problem

multi_pms_properties injects a domain into every relational field declared with
check_pms_properties=True, and that domain refers to the property field of the model:

https://github.com/OCA/pms/blob/16.0/multi_pms_properties/__init__.py#L51-L54

return f"['|', '|', \
    (not {prop1}, '=', True), \
    ('{coprop}', 'in', {prop2}), \
    ('{coprop}', '=', False)]"

On product.pricelist five fields carry that domain, item_ids among them, and on
product.pricelist.item four do, product_tmpl_id and pricelist_id among them. All of
them are displayed by the inherited core views without any group.

Odoo refuses to validate a view where a field used in the domain of another field is
restricted to a narrower group (ir_ui_view.py#L3053),
so adding groups="pms.group_pms_user" to pms_property_ids breaks the whole view:

odoo.tools.convert.ParseError: while parsing pms/views/product_pricelist_views.xml:3
Field 'pms_property_ids' used in domain of field 'item_ids'
(['|', '|', (not pms_property_ids, '=', True), ('pms_property_ids', 'in', pms_property_ids),
('pms_property_ids', '=', False)]) is restricted to the group(s) pms.group_pms_user.

The view no longer loads, so pms cannot be installed or updated on any database with
multi_pms_properties loaded through server_wide_modules. It is not a cosmetic issue.

Why CI did not catch it

The domain injection is gated on multi_pms_properties being in server_wide_modules,
which is not the case when running the test suite, so the injected domain never exists
there and the views validate fine.

For the record, I could not pin down why a fresh install passes while updating an existing
database fails, even with the patch active in both. I would rather say so than guess: the
failure is reproducible on update, and the fix below is correct regardless of the trigger.

Fix

Keep the field available for the remaining users with a hidden companion node, which is
the pattern core uses for company_id with check_company (61 occurrences of groups="!"
in core views), for instance
account_move_views.xml#L417-L418:

<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}" optional="hide"/>
<field name="company_id" groups="!base.group_multi_company" invisible="1"/>

The field stays available in the arch for every group combination while it is only
displayed to PMS users, so the intent of #440 is preserved.

Only two views need it. product_template_views.xml and res_partner_views.xml are left
untouched on purpose: the only check_pms_properties field of those models is
pms_property_ids itself, which is restricted to the same group that makes it mandatory,
so it is self-consistent.

Test

pms/tests/test_view_check_pms_properties.py validates the affected views with the domain
injection patched in explicitly, so it does not depend on server_wide_modules and
reproduces a real deployment instead of silently passing.

To be clear about what I did and did not verify: the failure and the fix are confirmed on
an update of an existing database, but I have not run this test suite myself, so I am
relying on this PR's CI for it. Please double check that it does fail without the view
changes; if it does not, the trigger is narrower than the test assumes and the test needs
work before it is worth keeping.

Also documented the invariant in multi_pms_properties usage, since this is an easy trap
to fall into again from any module adding groups to a property field.

multi_pms_properties injects a domain referring to the property field of the
model into every relational field declared with check_pms_properties=True.
product.pricelist.item_ids and product.pricelist.item.product_tmpl_id are among
them, and both are shown by the inherited core views without any group.

Odoo refuses to validate a view where a field used in the domain of another
field is restricted to a narrower group, so restricting pms_property_ids with
groups="pms.group_pms_user" makes the pricelist views fail validation:

  odoo.tools.convert.ParseError: while parsing product_pricelist_views.xml:3
  Field 'pms_property_ids' used in domain of field 'item_ids' is restricted to
  the group(s) pms.group_pms_user.

The view no longer loads, so the module cannot be installed or updated.

Keep the field available for the remaining users with a hidden companion node,
the same pattern core uses for company_id with check_company, so it is still
only displayed to PMS users. Add a test that validates the affected views with
the domain injection active.
…variant

Any view showing a field of a model with check_pms_properties fields must keep
pms_property_id(s) available for every group combination, otherwise Odoo cannot
validate it. Document the companion node pattern to hide it instead.
@OCA-git-bot OCA-git-bot added mod:pms Module pms series:16.0 mod:multi_pms_properties Module multi_pms_properties labels Aug 24, 2026
@DarioLodeiros

Copy link
Copy Markdown
Member Author

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-441-by-DarioLodeiros-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 8ecbe7c into OCA:16.0 Aug 24, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at c6ab9d1. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants