[FIX] web: resequence x2m in dialog form view
Before this commit, in the form view dialog of an x2m, resequencing an
x2m will cause a crash.
Why:
The basic_relatonal_model passes the wrong view type to the basic_model
when resequencing. In this case, we want to use the form view.
How to reproduce:
- Going into a form view with an editable x2m
- Open a record of the x2m in a form view dialog with an x2m containing
a handle field
- Change the order of the records using the handle field (resequence)
Before this commit:
A crash is displayed
After this commit:
The records have been resequenced correctly.
closes odoo/odoo#117145
X-original-commit: 003e6f27db767cd80758b868c8afbf73b78f1abe
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -1064,15 +1064,19 @@ export class StaticList extends DataPoint {
|
||||
this.model.__bm__.notifyChanges(
|
||||
parentID,
|
||||
{ [this.__fieldName__]: op },
|
||||
{ notifyChange: false }
|
||||
{ notifyChange: false, viewType: "form" }
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
await this.model.__bm__.notifyChanges(parentID, {
|
||||
[this.__fieldName__]: lastOperation,
|
||||
});
|
||||
await this.model.__bm__.notifyChanges(
|
||||
parentID,
|
||||
{
|
||||
[this.__fieldName__]: lastOperation,
|
||||
},
|
||||
{ viewType: "form" }
|
||||
);
|
||||
} finally {
|
||||
if (this.__viewType === "list") {
|
||||
await this.model.__bm__.setSort(this.__bm_handle__, handleField);
|
||||
|
||||
@@ -397,6 +397,73 @@ QUnit.module("Fields", (hooks) => {
|
||||
await click(target, ".o_field_many2one input");
|
||||
});
|
||||
|
||||
QUnit.test("resequence a x2m in a form view dialog from another x2m", async function (assert) {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
resId: 1,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="turtles">
|
||||
<tree>
|
||||
<field name="display_name"/>
|
||||
</tree>
|
||||
<form>
|
||||
<field name="partner_ids">
|
||||
<tree editable="top">
|
||||
<field name="int_field" widget="handle"/>
|
||||
<field name="display_name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</form>
|
||||
</field>
|
||||
</form>`,
|
||||
mockRPC(route, args) {
|
||||
assert.step(args.method);
|
||||
if (args.method === "write") {
|
||||
assert.deepEqual(Object.keys(args.args[1]), ["turtles"]);
|
||||
assert.strictEqual(args.args[1].turtles.length, 1);
|
||||
assert.deepEqual(args.args[1].turtles[0], [
|
||||
1,
|
||||
2,
|
||||
{
|
||||
partner_ids: [
|
||||
[6, false, [2, 4]],
|
||||
[1, 2, { int_field: 0 }],
|
||||
[1, 4, { int_field: 1 }],
|
||||
],
|
||||
},
|
||||
]);
|
||||
}
|
||||
},
|
||||
});
|
||||
assert.verifySteps(["get_views", "read", "read"]);
|
||||
|
||||
await click(target, ".o_data_cell");
|
||||
assert.containsOnce(target, ".modal");
|
||||
assert.deepEqual(
|
||||
[...target.querySelectorAll(".modal [name='display_name']")].map(
|
||||
(el) => el.textContent
|
||||
),
|
||||
["aaa", "second record"]
|
||||
);
|
||||
assert.verifySteps(["read", "read"]);
|
||||
|
||||
await dragAndDrop(".modal tr:nth-child(2) .o_handle_cell", "tbody tr", "top");
|
||||
assert.deepEqual(
|
||||
[...target.querySelectorAll(".modal [name='display_name']")].map(
|
||||
(el) => el.textContent
|
||||
),
|
||||
["second record", "aaa"]
|
||||
);
|
||||
assert.verifySteps([]);
|
||||
|
||||
await clickSave(target.querySelector(".modal"));
|
||||
await clickSave(target);
|
||||
assert.verifySteps(["write", "read", "read"]);
|
||||
});
|
||||
|
||||
QUnit.test("one2many list editable with cell readonly modifier", async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user