[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
<tree>
<field name="many2one" domain="[['someField', '=', context.get('some_key')]]" />
</tree>
```
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) <aab@odoo.com>
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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: `
|
||||
<tree editable="bottom">
|
||||
<field name="m2o" domain="[['someField', '=', context.get('default_global_key', 'nope')]]"/>
|
||||
</tree>
|
||||
`,
|
||||
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"]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user