diff --git a/addons/web/static/src/views/list/list_controller.js b/addons/web/static/src/views/list/list_controller.js
index e922beb61fc..3d774eebbcc 100644
--- a/addons/web/static/src/views/list/list_controller.js
+++ b/addons/web/static/src/views/list/list_controller.js
@@ -494,7 +494,11 @@ export class ListController extends Component {
});
}
- async beforeExecuteActionButton(clickParams) {}
+ async beforeExecuteActionButton(clickParams) {
+ if (clickParams.special !== "cancel" && this.model.root.editedRecord) {
+ return this.model.root.editedRecord.save();
+ }
+ }
async afterExecuteActionButton(clickParams) {}
}
diff --git a/addons/web/static/src/views/list/list_renderer.xml b/addons/web/static/src/views/list/list_renderer.xml
index 2e14e73f315..ced2c91d4b3 100644
--- a/addons/web/static/src/views/list/list_renderer.xml
+++ b/addons/web/static/src/views/list/list_renderer.xml
@@ -245,7 +245,7 @@
className="button.className"
clickParams="button.clickParams"
defaultRank="button.defaultRank"
- disabled="record.isVirtual || button.disabled"
+ disabled="button.disabled"
icon="button.icon"
record="record"
string="button.string"
diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js
index 130657ac183..261d0d2acfb 100644
--- a/addons/web/static/tests/views/list_view_tests.js
+++ b/addons/web/static/tests/views/list_view_tests.js
@@ -7365,8 +7365,8 @@ QUnit.module("Views", (hooks) => {
);
assert.strictEqual(
target.querySelector(".o_list_button button").disabled,
- true,
- "buttons should be disabled while the record is not yet created"
+ false,
+ "buttons should not be disabled while the record is not yet created"
);
await clickSave(target);
@@ -7394,6 +7394,14 @@ QUnit.module("Views", (hooks) => {
`,
+ mockRPC(route, { method }) {
+ if (method === "create") {
+ assert.step("create");
+ } else if (route === "/web/dataset/call_button") {
+ assert.step("call_button");
+ return true;
+ }
+ },
});
await click(target.querySelector(".o_list_button_add"));
@@ -7403,6 +7411,16 @@ QUnit.module("Views", (hooks) => {
"table button i.o_button_icon.fa-phone",
"should have rendered a button"
);
+ assert.notOk(
+ target.querySelector("table button").disabled,
+ "button should not be disabled when creating the record"
+ );
+
+ await click(target, "table button");
+ assert.verifySteps(
+ ["create", "call_button"],
+ "clicking the button should save the record and then execute the action"
+ );
});
QUnit.test("list view with a button without icon", async function (assert) {