[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
This commit is contained in:
luvi
2023-01-17 14:16:53 +01:00
parent 20f5e0f708
commit 6a74bfae9f
2 changed files with 14 additions and 9 deletions
@@ -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();
});
@@ -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") {