[FIX] web: x2m multi page with context with parent key

Part-of: odoo/odoo#114024
This commit is contained in:
FrancoisGe
2023-07-24 20:17:51 +02:00
committed by Aaron Bohy
parent cd6d54d7bf
commit a189424ff4
2 changed files with 40 additions and 1 deletions
@@ -775,7 +775,10 @@ export class StaticList extends DataPoint {
const currentIds = nextCurrentIds.slice(offset, offset + limit);
const resIds = this._getResIdsToLoad(currentIds);
if (resIds.length) {
const records = await this.model._loadRecords({ ...this.config, resIds });
const records = await this.model._loadRecords(
{ ...this.config, resIds },
this.evalContext
);
for (const record of records) {
this._createRecordDatapoint(record);
}
@@ -5086,6 +5086,42 @@ QUnit.module("Fields", (hooks) => {
}
);
QUnit.test(
"one2many list, multi page, with many2one and with context with parent key",
async function (assert) {
serverData.models.partner.records[0].turtles = [1, 2, 3];
await makeView({
type: "form",
resModel: "partner",
serverData,
arch: `
<form>
<field name="foo"/>
<field name="turtles">
<tree limit="2">
<field name="product_id" context="{'partner_foo': parent.foo}"/>
</tree>
</field>
</form>`,
resId: 1,
mockRPC(route, { method, model, kwargs }) {
if (method === "web_read" && model === "turtle") {
assert.step("web_read turtle");
assert.deepEqual(
kwargs.specification.product_id.context,
{ partner_foo: "yop" },
"should have correctly evaluated parent foo field"
);
}
},
});
await click(target, ".o_x2m_control_panel .o_pager_next");
assert.verifySteps(["web_read turtle"]);
}
);
QUnit.test("one2many list, editable, with a date in the context", async function (assert) {
assert.expect(1);