From 6a74bfae9fa4d737c7ad41a984e581df8bfb5397 Mon Sep 17 00:00:00 2001 From: luvi Date: Sun, 8 Jan 2023 11:33:23 +0000 Subject: [PATCH] [FIX] web: fix export templates list filtering Before this commit, exporting templates were not filtered as expected. It means templates were visible even on other domains, polluting the list of templates of a model. This restores the legacy behavior by filtering the domain in the rpc and only displaying the desired template list. A test has been modified to verify the presence of the domain filter in the parameters of the rpc. task #3127779 X-original-commit: 30a673c044e53bfb1edc1e6733b2c83c67e0232c Part-of: odoo/odoo#110126 --- .../src/views/view_dialogs/export_data_dialog.js | 14 +++++++------- .../views/view_dialogs/export_data_dialog_tests.js | 9 +++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/addons/web/static/src/views/view_dialogs/export_data_dialog.js b/addons/web/static/src/views/view_dialogs/export_data_dialog.js index 0cfbefa9b13..1853ff006f2 100644 --- a/addons/web/static/src/views/view_dialogs/export_data_dialog.js +++ b/addons/web/static/src/views/view_dialogs/export_data_dialog.js @@ -109,14 +109,14 @@ export class ExportDataDialog extends Component { onWillStart(async () => { this.availableFormats = await this.rpc("/web/export/formats"); - this.templates = await this.rpc("/web/dataset/call_kw", { - args: [], - kwargs: { + this.templates = await this.orm.searchRead( + "ir.exports", + [["resource", "=", this.props.root.resModel]], + [], + { context: this.props.context, - }, - model: "ir.exports", - method: "search_read", - }); + } + ); await this.fetchFields(); }); diff --git a/addons/web/static/tests/views/view_dialogs/export_data_dialog_tests.js b/addons/web/static/tests/views/view_dialogs/export_data_dialog_tests.js index 2d0469b27b2..fabe116c782 100644 --- a/addons/web/static/tests/views/view_dialogs/export_data_dialog_tests.js +++ b/addons/web/static/tests/views/view_dialogs/export_data_dialog_tests.js @@ -231,7 +231,7 @@ QUnit.module("ViewDialogs", (hooks) => { }); QUnit.test("Export dialog: interacting with export templates", async function (assert) { - assert.expect(25); + assert.expect(26); await makeView({ serverData, @@ -250,7 +250,12 @@ QUnit.module("ViewDialogs", (hooks) => { ); return 2; } - if (route === "/web/dataset/call_kw") { + if (args.method === "search_read") { + assert.deepEqual( + args.kwargs.domain, + [["resource", "=", "partner"]], + "rpc contains the right domain filter to fetch templates" + ); return Promise.resolve([{ id: 1, name: "Activities template" }]); } if (route === "/web/export/namelist") {