[FIX] web: header button with display="always" and invisible

Since the commit odoo/odoo@0d99f4b9d9, the header buttons with display="always"
can't be invisible. The invisible attribute is ignored for this type of
button in list view and kanban view.

This commit fixes this issue by adding t-if that will evaluate the invisible attribute.

closes odoo/odoo#148092

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
FrancoisGe
2024-01-05 08:00:41 +00:00
parent c5b19f1765
commit e0109a99f8
4 changed files with 19 additions and 11 deletions
@@ -15,7 +15,7 @@
<t t-call="{{ props.buttonTemplate }}"/>
</t>
<t t-set-slot="control-panel-always-buttons">
<t t-foreach="headerButtons" t-as="button" t-key="button.id">
<t t-foreach="headerButtons" t-as="button" t-key="button.id" t-if="!evalViewModifier(button.invisible)">
<MultiRecordViewButton
t-if="button.display === 'always'"
list="model.root"
@@ -16,7 +16,7 @@
<t t-call="{{ props.buttonTemplate }}"/>
</t>
<t t-set-slot="control-panel-always-buttons">
<t t-foreach="archInfo.headerButtons" t-as="button" t-key="button.id">
<t t-foreach="archInfo.headerButtons" t-as="button" t-key="button.id" t-if="!evalViewModifier(button.invisible)">
<MultiRecordViewButton
t-if="button.display === 'always'"
list="model.root"
@@ -13811,6 +13811,8 @@ QUnit.module("Views", (hooks) => {
<kanban class="o_kanban_test">
<header>
<button name="display" type="object" class="display" string="display" display="always"/>
<button name="display" type="object" class="display_invisible" string="invisible 1" display="always" invisible="1"/>
<button name="display" type="object" class="display_invisible_2" string="invisible context" display="always" invisible="context.get('a')"/>
<button name="default-selection" type="object" class="default-selection" string="default-selection"/>
</header>
<field name="bar" />
@@ -13823,6 +13825,9 @@ QUnit.module("Views", (hooks) => {
</templates>
</kanban>`,
domain,
context: {
a: true,
},
});
patchWithCleanup(kanban.env.services.action, {
doActionButton: async (params) => {
@@ -13840,6 +13845,7 @@ QUnit.module("Views", (hooks) => {
});
assert.deepEqual(context, {
a: true,
lang: "en",
tz: "taht",
uid: 7,
@@ -603,15 +603,12 @@ QUnit.module("Views", (hooks) => {
triggerHotkey("control+k");
await nextTick();
assert.deepEqual(
getNodesTextContent(target.querySelectorAll(".o_command_hotkey")),
[
"NewALT + C",
"ActionsALT + U",
"Search...ALT + Q",
"Toggle search panelALT + SHIFT + Q"
]
);
assert.deepEqual(getNodesTextContent(target.querySelectorAll(".o_command_hotkey")), [
"NewALT + C",
"ActionsALT + U",
"Search...ALT + Q",
"Toggle search panelALT + SHIFT + Q",
]);
});
QUnit.test('list with delete="0"', async function (assert) {
@@ -1029,10 +1026,15 @@ QUnit.module("Views", (hooks) => {
<tree>
<header>
<button name="display" type="object" class="display" string="display" display="always"/>
<button name="display" type="object" class="display_invisible" string="invisible 1" display="always" invisible="1"/>
<button name="display" type="object" class="display_invisible" string="invisible context" display="always" invisible="context.get('a')"/>
<button name="default-selection" type="object" class="default-selection" string="default-selection"/>
</header>
<field name="foo" />
</tree>`,
context: {
a: true,
},
});
let cpButtons = getVisibleButtons(target);
assert.deepEqual(