diff --git a/addons/web/static/src/views/form/form_compiler.js b/addons/web/static/src/views/form/form_compiler.js index 0316e82beb9..a31e3f3b06f 100644 --- a/addons/web/static/src/views/form/form_compiler.js +++ b/addons/web/static/src/views/form/form_compiler.js @@ -144,7 +144,11 @@ export class FormCompiler extends ViewCompiler { ? `!evalDomainFromRecord(props.record,${JSON.stringify(invisible)})` : true, }); - append(mainSlot, this.compileNode(child, params, false)); + const button = this.compileNode(child, params, false); + if (button.tagName === "ViewButton") { + button.setAttribute("defaultRank", "'oe_stat_button'"); + } + append(mainSlot, button); append(buttonBox, mainSlot); } diff --git a/addons/web/static/tests/views/form/form_view_tests.js b/addons/web/static/tests/views/form/form_view_tests.js index 28272ccac27..de87d623b91 100644 --- a/addons/web/static/tests/views/form/form_view_tests.js +++ b/addons/web/static/tests/views/form/form_view_tests.js @@ -1477,6 +1477,34 @@ QUnit.module("Views", (hooks) => { await click(target.querySelector(".oe_stat_button")); // should not call doActionButton }); + QUnit.test("rendering stat buttons without class", async function (assert) { + await makeView({ + type: "form", + resModel: "partner", + serverData, + arch: ` +
+ +
+ +
+ + + +
+
`, + resId: 2, + }); + + assert.containsOnce( + target, + "button.oe_stat_button", + "button should have oe_stat_button class" + ); + }); + QUnit.test("rendering stat buttons without action", async function (assert) { await makeView({ type: "form",