From a480ee6aec1f248e80375025023a49a89232b40e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roc=C3=ADo=20Vega?= Date: Tue, 18 Aug 2026 14:07:57 +0000 Subject: [PATCH 1/2] [FIX] portal_backend: assert the parent menus group on registry load Granting base.group_user to the parent menus without group was done while loading the menus, but /web/webclient/load_menus is a readonly route, so the write breaks its cursor with "cannot execute INSERT in a read-only transaction". The request itself survives -it is retried with a read/write cursor- but the failed query is already logged as an error, which is enough to turn a test run red. On a real database it happened once, since the retry commits the group; on tests it happens on every tour that loads the webclient, because each test rolls that write back. Doing it on _register_hook keeps the case covered -another module installing a parent menu without internal group after portal_backend- and runs on a read/write cursor: the hook is called when the registry is loaded, which is what installing or updating a module does. closes ingadhoc/miscellaneous#436 Related: ingadhoc/stock#1004 Related: ingadhoc/account-financial-tools#984 Related: ingadhoc/product#937 Signed-off-by: Filoquin adhoc --- portal_backend/models/ir_ui_menu.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/portal_backend/models/ir_ui_menu.py b/portal_backend/models/ir_ui_menu.py index 2ef6ecb1..80fd78fd 100644 --- a/portal_backend/models/ir_ui_menu.py +++ b/portal_backend/models/ir_ui_menu.py @@ -1,18 +1,22 @@ -from odoo import Command, api, models, tools +from odoo import Command, models class IrUiMenu(models.Model): _inherit = "ir.ui.menu" - @api.model - @tools.ormcache("self.env.uid", "debug", "self.env.lang") - def load_menus(self, debug): - """Assert all parent menus has internal group.""" - # NOTE: - # It is important to do it here to capture the case when portal_backend is already installed and the user - # installs another module with a parent menu without internal group. + def _register_hook(self): + """Assert all parent menus have internal group. + + NOTE: + It is done on registry load to capture the case when portal_backend is already installed and the user + installs another module with a parent menu without internal group. + It can not be done while loading the menus: that route is readonly, so writing there breaks its cursor + with "cannot execute INSERT in a read-only transaction" (the request is retried with a read/write one, + but the failed query is already logged as an error). + """ + super()._register_hook() parent_menus_wo_group = self.sudo().search([("parent_id", "=", False), ("group_ids", "=", False)]) - parent_menus_wo_group.with_context(from_config=True).write( - {"group_ids": [Command.link(self.env.ref("base.group_user").id)]} - ) - return super().load_menus(debug=debug) + if parent_menus_wo_group: + parent_menus_wo_group.with_context(from_config=True).write( + {"group_ids": [Command.link(self.env.ref("base.group_user").id)]} + ) From 3a75a145be62be42cc67d92763d8294c9f7ec602 Mon Sep 17 00:00:00 2001 From: roboadhoc Date: Wed, 26 Aug 2026 14:09:25 +0000 Subject: [PATCH 2/2] [BOT] Bump version: portal_backend 19.0.1.3.0 Merged: ingadhoc/miscellaneous#436 --- portal_backend/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portal_backend/__manifest__.py b/portal_backend/__manifest__.py index ee62c560..f3570560 100644 --- a/portal_backend/__manifest__.py +++ b/portal_backend/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { "name": "Portal Backend", - "version": "19.0.1.2.0", + "version": "19.0.1.3.0", "category": "Base", "sequence": 14, "summary": "",