From d678d516ef74de983dcaed8c0ed8cc39a0af0669 Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Tue, 17 Mar 2020 08:26:23 +0000 Subject: [PATCH] [FIX] web: action menus default select_all Before this commit, the context sent by an action performed by the action menu could hold an 'undefined' select_all key, which would cause the context evaluation to crash. Now, the select_all key is defaulted to 'false' and does not crash in actions that do not provide it. closes odoo/odoo#47745 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/components/action_menus.js | 9 +++------ addons/web/static/tests/components/action_menus_tests.js | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/components/action_menus.js b/addons/web/static/src/js/components/action_menus.js index d94e162ca44..69a10423373 100644 --- a/addons/web/static/src/js/components/action_menus.js +++ b/addons/web/static/src/js/components/action_menus.js @@ -99,19 +99,16 @@ odoo.define('web.ActionMenus', function (require) { active_id: this.props.activeIds[0], active_ids: this.props.activeIds, active_model: this.env.action.res_model, - select_all: this.props.selectAll, + select_all: this.props.selectAll || false, }; if (this.props.domain) { activeIdsContext.active_domain = this.props.domain; } - const context = pyUtils.eval('context', new Context(this.props.context, activeIdsContext)); + const context = new Context(this.props.context, activeIdsContext).eval(); const result = await this.rpc({ route: '/web/action/load', - params: { - action_id: action.id, - context: context, - }, + params: { action_id: action.id, context }, }); result.context = new Context(result.context || {}, activeIdsContext) .set_eval_context(context); diff --git a/addons/web/static/tests/components/action_menus_tests.js b/addons/web/static/tests/components/action_menus_tests.js index e17ae95ba78..f4229b30493 100644 --- a/addons/web/static/tests/components/action_menus_tests.js +++ b/addons/web/static/tests/components/action_menus_tests.js @@ -105,6 +105,7 @@ odoo.define('web.action_menus_tests', function (require) { active_id: 23, active_ids: [23], active_model: 'hobbit', + select_all: false, // default props }; assert.deepEqual(args.context, expectedContext); assert.step('load-action'); @@ -177,6 +178,7 @@ odoo.define('web.action_menus_tests', function (require) { active_id: 23, active_ids: [23], active_model: 'hobbit', + select_all: false, // default props }; assert.deepEqual(args.context, expectedContext); assert.step('load-action');