[FIX] point_of_sale: prevent menu_service from loading

This commit is a copy of 7ddcebfc, which was reverted in dfcfe63c.

Before this commit, the menu_service was not included into the
`pos.assets_backend` bundle which was fine until we had to add
a dependency to `menu_service` in a file which is included in
`web.assets_backend`. Since pos.assets_backend imports pratically
all `web.assets_backend` bundle, there was dependencies errors.

The sublient issue is that the pos bundle was built relying on a
specific feature (the primary copy of Qweb templates) which was
dropped when we introduced the new assets manager (8cc06617).

There a two other approaches that we could consider:
- Create a new bundle `web.assets_backend_primary` that would be
  called separately by `web.assets_backend`and `pos_assets_backend`,
  it would mimic the dropped behaviour
- Change the `pos_assets_backend` to manually call every specific
  element they need to function, which would prevent the depepdencies
  issues

Unfortunately, both solutions are not realistic on a stable release,
which is why we chose to reintroduce this patch, and will fix the POS
bundle properly in master, where the side-effects can be handled.

After this commit, there are no dependency issues, and the menus
are not loaded, as expected and as before.

Part of task 2860257

closes odoo/odoo#92324

X-original-commit: b077fe72e8d9338e802cbceb580f3abcb6938462
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
Lucas Perais (lpe)
2022-05-25 22:31:20 +02:00
committed by Rémi Rahir
parent 2d75013ff0
commit 9abc032a10
2 changed files with 3 additions and 1 deletions
-1
View File
@@ -100,7 +100,6 @@
'point_of_sale.pos_assets_backend': [
('include', 'web.assets_common'),
('include', 'web.assets_backend'),
('remove', 'web/static/src/webclient/menus/menu_service.js'),
('remove', 'web/static/src/core/errors/error_handlers.js'),
('remove', 'web/static/src/legacy/legacy_rpc_error_handler.js'),
],
@@ -33,6 +33,9 @@
'pos_session_id': pos_session_id,
'debug': debug,
})"/>;
// Prevent the menu_service to load anything. In an ideal world, POS assets would only contain
// what is genuinely necessary, and not the whole backend.
odoo.loadMenusPromise = Promise.resolve();
odoo.loadTemplatesPromise = fetch(`/web/webclient/qweb/${odoo.__session_info__.cache_hashes.qweb}?bundle=web.assets_qweb`).then(doc => doc.text());
</script>