Skip to content

Conversation

@tishmen
Copy link

@tishmen tishmen commented Oct 9, 2025

Scope

  • base_user_role_company only

Summary

  • Migrate to Odoo 19.0 following OCA guide.
  • Override parent unique constraint with company-aware one: UNIQUE(user_id, role_id, company_id).
  • Tests aligned with 19.0 (group_ids API).

Pre-commit

  • Verified locally; no additional changes applied beyond auto-fixes.

Temporary dependency

  • Added a temporary reference in root test-requirements.txt to install base_user_role from the PR ref, per OCA guidelines.

Tests

Command:

./odoo/odoo-bin -c odoo.conf -d bur19_tests_burco -i base_user_role,base_user_role_company --test-enable --test-tags "/base_user_role_company" --without-demo=all --log-level=info --stop-after-init

Result: green locally.

Depends on:

Chandresh-OSI and others added 30 commits October 9, 2025 13:51
Currently translated at 100.0% (11 of 11 strings)

Translation: server-backend-14.0/server-backend-14.0-base_user_role_company
Translate-URL: https://translation.odoo-community.org/projects/server-backend-14-0/server-backend-14-0-base_user_role_company/it/
Issue found on logout / relogin.
The user groups were applied correctly, but the main menu showed apps
the user did not have access to.

This was related to the menu caching mechanisn, that was disabled here.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-backend-14.0/server-backend-14.0-base_user_role_company
Translate-URL: https://translation.odoo-community.org/projects/server-backend-14-0/server-backend-14-0-base_user_role_company/
Currently translated at 90.9% (10 of 11 strings)

Translation: server-backend-14.0/server-backend-14.0-base_user_role_company
Translate-URL: https://translation.odoo-community.org/projects/server-backend-14-0/server-backend-14-0-base_user_role_company/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-backend-16.0/server-backend-16.0-base_user_role_company
Translate-URL: https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-base_user_role_company/
Currently translated at 100.0% (8 of 8 strings)

Translation: server-backend-16.0/server-backend-16.0-base_user_role_company
Translate-URL: https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-base_user_role_company/es/
Currently translated at 100.0% (8 of 8 strings)

Translation: server-backend-16.0/server-backend-16.0-base_user_role_company
Translate-URL: https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-base_user_role_company/pt/
Currently translated at 100.0% (8 of 8 strings)

Translation: server-backend-16.0/server-backend-16.0-base_user_role_company
Translate-URL: https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-base_user_role_company/es/
Currently translated at 100.0% (8 of 8 strings)

Translation: server-backend-16.0/server-backend-16.0-base_user_role_company
Translate-URL: https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-base_user_role_company/it/
@tishmen tishmen marked this pull request as ready for review October 9, 2025 13:22
@tishmen tishmen marked this pull request as draft October 9, 2025 13:24
@tishmen
Copy link
Author

tishmen commented Oct 9, 2025

Depends on #382.

Temporary dependency

Highlights

  • Unique constraint overridden to UNIQUE (user_id, role_id, company_id).
  • Company‑aware role enablement honored via active_company_ids.
  • Local tests green. Command used:
./odoo/odoo-bin -c odoo.conf -d bur19_tests_burco -i base_user_role,base_user_role_company --test-enable --test-tags "/base_user_role_company" --without-demo=all --log-level=info --stop-after-init

Maintainers ping

Kept as draft until #382 is approved/merged; can flip to ready on request.

- Replace groups_id with group_ids in views/actions
- Bump version to 19.0.1.0.0; adjust manifests/assets
- Use env attributes and Domain expressions
- Adopt new Constraint/Index APIs where applicable

Functional changes
@tishmen tishmen force-pushed the 19.0-mig-base_user_role_company branch from 567e0c0 to c688a95 Compare October 15, 2025 18:38
@tishmen tishmen marked this pull request as ready for review October 15, 2025 18:41
@much-filipe-colaco
Copy link

much-filipe-colaco commented Jan 28, 2026

@tishmen I attempted to install this migrated version of base_user_role_company on a local instance of Odoo 19.0. The installation seemed to work, but trying to access the home page the error below is logged.
Python version: 3.12.3

2026-01-28 18:11:34,490 282 ERROR dummy odoo.http: Exception during request handling. 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 2785, in __call__
    response = request._serve_db()
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 2268, in _serve_db
    raise self._update_served_exception(exc)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 2266, in _serve_db
    return service_model.retrying(serve_func, env=self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 184, in retrying
    result = func()
             ^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 2313, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 2435, in dispatch
    return self.request.registry['ir.http']._dispatch(endpoint)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 357, in _dispatch
    result = endpoint(**request.params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 788, in route_wrapper
    result = endpoint(self, *args, **params_ok)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/odoo/custom/addons/base_user_role_company/controllers/main.py", line 17, in web_load_menus
    del response.headers["Cache-Control"]
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
AttributeError: __delitem__

I looked at alternative solutions and found that the following option works (source).

    def web_load_menus(self, lang=None):
        # v19 signature: (lang=None). Keep behavior of disabling menu HTTP cache.
        response = super().web_load_menus(lang=lang)
        # Remove Cache-Control header to disable menu HTTP caching
        # Using .pop() as Werkzeug Headers no longer supports __delitem__ (del)
        response.headers.pop("Cache-Control", None)
        return response

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.