[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) <aab@odoo.com>
This commit is contained in:
Julien Mougenot
2020-03-17 08:26:25 +00:00
parent 7cdf8c25a6
commit d678d516ef
2 changed files with 5 additions and 6 deletions
@@ -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);
@@ -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');