From 84a96c1838f2d0f1c7ea26c0f72ffa09780b965c Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Wed, 27 Jul 2022 12:45:12 +0000 Subject: [PATCH] [FIX] web: default class for buttons in a button_box MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the buttons without classes in a button_box were assigned the default btn-secondary. Now, the default class for the buttons without classes in a button_box is the class oe_stat_button closes odoo/odoo#96881 Signed-off-by: Géry Debongnie --- .../static/src/views/form/form_compiler.js | 6 +++- .../tests/views/form/form_view_tests.js | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) 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",