From 152be24c17d1701d76276b454ff49b0b1fe43ea2 Mon Sep 17 00:00:00 2001 From: Lucas Perais Date: Mon, 17 Oct 2022 19:56:12 +0000 Subject: [PATCH] [FIX] web: RelationalModel: pass view's context down to evalContext Have some keys in the context passed to a view. Have a many2x field in that view that uses those keys in its domain with some flavor of: ```xml ``` Before this commit, the global context was not added to the evalContext used to evaluate the domain. After this commit, it is. closes odoo/odoo#103370 X-original-commit: 93c5e6cbc06bdb6ab2cfc959b68be8088837e1de Signed-off-by: Aaron Bohy (aab) Signed-off-by: Lucas Perais (lpe) --- .../web/static/src/views/relational_model.js | 1 + .../web/static/tests/views/list_view_tests.js | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/addons/web/static/src/views/relational_model.js b/addons/web/static/src/views/relational_model.js index e49b4291bb2..0295b0afbd9 100644 --- a/addons/web/static/src/views/relational_model.js +++ b/addons/web/static/src/views/relational_model.js @@ -471,6 +471,7 @@ export class Record extends DataPoint { return { // ... ...this.dataContext, + ...this.context, active_id: this.resId || false, active_ids: this.resId ? [this.resId] : [], active_model: this.resModel, diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index 05113f77cb5..434c438ce62 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -15780,4 +15780,30 @@ QUnit.module("Views", (hooks) => { ["Value 3", "Value 2", "Value 1", "Value 1"] ); }); + + QUnit.test("view's context is passed down as evalContext", async (assert) => { + await makeView({ + type: "list", + resModel: "foo", + serverData, + context: { + default_global_key: "some_value", + }, + arch: ` + + + + `, + mockRPC(_, args) { + if (args.method === "name_search") { + assert.step(`name_search`); + assert.deepEqual(args.kwargs.args, [["someField", "=", "some_value"]]); + } + }, + }); + + await click(target, ".o_data_row:nth-child(1) td.o_list_many2one"); + await click(target, ".o_field_many2one_selection .o-autocomplete--input"); + assert.verifySteps(["name_search"]); + }); });