[FIX] web: click on button doesn't save

Problem:
In a list view, editing a record and then clicking an action button
on that record does not save the edited field values.

Expected behaviour:
Changes applied to the record must be saved before executing the button
action.

Solution:
The 46bd694c8a67f25470a911c1eb04e0bf2e17a5f7 commit in master solves
this problem (TaskID-3132960). We will backport it and add a test for
our use case.

How to reproduce:
- Go to a list view with one text field and one button action per record
- Edit the text field
- Click on the button action

Before this commit:
The value of the text field has been restored. We lost our modification.

After this commit:
The record has been saved.

closes odoo/odoo#113120

Taskid: 3168517
X-original-commit: 5f5040730707e62885757aa6a39345a46cda9b48
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Georis François (fge) <fge@odoo.com>
This commit is contained in:
FrancoisGe
2023-02-21 11:25:42 +01:00
parent 8dbf2e1ce4
commit 354d311b3c
@@ -1005,6 +1005,50 @@ QUnit.module("Views", (hooks) => {
}
);
QUnit.test(
"list view: click on an action button saves the record before executing the action",
async function (assert) {
await makeView({
type: "list",
resModel: "foo",
serverData,
arch: `
<tree editable="bottom">
<field name="foo" />
<button name="toDo" type="object" class="do_something" string="Do Something"/>
</tree>`,
mockRPC: async (route, args) => {
assert.step(args.method);
if (route === "/web/dataset/call_button") {
return true;
}
},
});
await click(target.querySelector(".o_data_cell"));
await editInput(target, ".o_data_row [name='foo'] input", "plop");
assert.strictEqual(
target.querySelector(".o_data_row [name='foo'] input").value,
"plop"
);
await click(target.querySelector(".o_data_row button"));
assert.strictEqual(
target.querySelector(".o_data_row [name='foo']").textContent,
"plop"
);
assert.verifySteps([
"get_views",
"web_search_read",
"write",
"read",
"toDo",
"web_search_read",
]);
}
);
QUnit.test(
"list view: action button executes action on click: correct parameters",
async function (assert) {