From e00ba982d3be23fcd2bf8e136b71e191e36fe76a Mon Sep 17 00:00:00 2001 From: DarioLodeiros Date: Mon, 24 Aug 2026 20:05:57 +0200 Subject: [PATCH 1/2] [FIX] pms: keep pms_property_ids available when restricting it by group 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. --- pms/tests/__init__.py | 1 + pms/tests/test_view_check_pms_properties.py | 43 +++++++++++++++++++++ pms/views/product_pricelist_item_views.xml | 8 ++++ pms/views/product_pricelist_views.xml | 11 ++++++ 4 files changed, 63 insertions(+) create mode 100644 pms/tests/test_view_check_pms_properties.py diff --git a/pms/tests/__init__.py b/pms/tests/__init__.py index 910f749b93..e12f0127e7 100644 --- a/pms/tests/__init__.py +++ b/pms/tests/__init__.py @@ -46,3 +46,4 @@ from . import test_pms_payment from . import test_res_partner from . import test_pms_property +from . import test_view_check_pms_properties diff --git a/pms/tests/test_view_check_pms_properties.py b/pms/tests/test_view_check_pms_properties.py new file mode 100644 index 0000000000..dea884522a --- /dev/null +++ b/pms/tests/test_view_check_pms_properties.py @@ -0,0 +1,43 @@ +# Copyright 2026 Commit [Sun] +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from unittest.mock import patch + +from odoo import fields +from odoo.tests import common + +from odoo.addons.multi_pms_properties import _description_domain + + +class TestViewCheckPmsProperties(common.TransactionCase): + """Views must keep the property field available for every group combination. + + ``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 (``pms_property_ids`` or ``pms_property_id``). Odoo refuses + to validate a view where a field used in the domain of another field is + restricted to a narrower group, so restricting the property field with + ``groups`` breaks the whole view, and with it the module load. + + The injection only happens when ``multi_pms_properties`` is loaded through + ``server_wide_modules``, which is not the case while running tests. The patch + is therefore applied explicitly here, so the check reproduces a real + deployment instead of silently passing. + """ + + # Views showing fields whose injected domain refers to the property field + VIEWS = [ + "pms.product_pricelist_view_form", + "pms.product_pricelist_item_view_form", + "pms.product_template_view_form", + "pms.res_partner_view_form", + ] + + def test_views_validate_with_injected_property_domain(self): + with patch.object( + fields._Relational, "check_pms_properties", False, create=True + ), patch.object( + fields._Relational, "_description_domain", _description_domain, create=True + ): + for xml_id in self.VIEWS: + with self.subTest(view=xml_id): + self.env.ref(xml_id)._check_xml() diff --git a/pms/views/product_pricelist_item_views.xml b/pms/views/product_pricelist_item_views.xml index 279f0629c3..e8498c9322 100644 --- a/pms/views/product_pricelist_item_views.xml +++ b/pms/views/product_pricelist_item_views.xml @@ -27,6 +27,14 @@ widget="many2many_tags" options="{'no_create': True,'no_open': True}" /> + + Date: Mon, 24 Aug 2026 20:05:57 +0200 Subject: [PATCH 2/2] [IMP] multi_pms_properties: document the check_pms_properties view invariant 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. --- multi_pms_properties/README.rst | 9 +++++++++ multi_pms_properties/readme/USAGE.rst | 9 +++++++++ multi_pms_properties/static/description/index.html | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/multi_pms_properties/README.rst b/multi_pms_properties/README.rst index 3435c0c5f5..979da5b158 100644 --- a/multi_pms_properties/README.rst +++ b/multi_pms_properties/README.rst @@ -59,6 +59,15 @@ Usage ``check_pms_properties like field attribute to check relational record properties consistence`` ``This module not implement propety dependent fields`` +* ``check_pms_properties`` injects a domain referring to the property field of the + model, so any view showing such a field must keep ``pms_property_id(s)`` + available for every group combination. Restricting it with ``groups`` makes Odoo + refuse to validate the view. To hide it from some users, add a companion node + instead, the same way core does with ``company_id`` and ``check_company``:: + + + + Bug Tracker =========== diff --git a/multi_pms_properties/readme/USAGE.rst b/multi_pms_properties/readme/USAGE.rst index daa058b5f3..df817d6869 100644 --- a/multi_pms_properties/readme/USAGE.rst +++ b/multi_pms_properties/readme/USAGE.rst @@ -3,3 +3,12 @@ ``_check_pms_properties_auto like model attribute to autocheck on create/write`` ``check_pms_properties like field attribute to check relational record properties consistence`` ``This module not implement propety dependent fields`` + +* ``check_pms_properties`` injects a domain referring to the property field of the + model, so any view showing such a field must keep ``pms_property_id(s)`` + available for every group combination. Restricting it with ``groups`` makes Odoo + refuse to validate the view. To hide it from some users, add a companion node + instead, the same way core does with ``company_id`` and ``check_company``:: + + + diff --git a/multi_pms_properties/static/description/index.html b/multi_pms_properties/static/description/index.html index 01037cc4fa..e843ab757d 100644 --- a/multi_pms_properties/static/description/index.html +++ b/multi_pms_properties/static/description/index.html @@ -406,6 +406,16 @@

Usage

check_pms_properties like field attribute to check relational record properties consistence This module not implement propety dependent fields

+
  • check_pms_properties injects a domain referring to the property field of the +model, so any view showing such a field must keep pms_property_id(s) +available for every group combination. Restricting it with groups makes Odoo +refuse to validate the view. To hide it from some users, add a companion node +instead, the same way core does with company_id and check_company:

    +
    +<field name="pms_property_ids" groups="pms.group_pms_user" />
    +<field name="pms_property_ids" groups="!pms.group_pms_user" invisible="1" />
    +
    +