[FIX] web: disabled button in list view

Before this commit, setting a disabled attribute on a <button> tag in
the arch of a list view was ignored.

How to reproduce:
Going into a list view with a <button disabled="1"> tag.
Click on the button

Before this commit:
The button is not disabled and a crash is displayed on click.

After this commit:
The button is correctly disabled and there is no crash on click.

closes odoo/odoo#109337

X-original-commit: c8ef3262e3aa167a520dcb0d1b229e61e5e2e362
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
FrancoisGe
2023-01-11 08:29:43 +01:00
parent 4b9894c4a4
commit e2cb2e7d23
3 changed files with 23 additions and 2 deletions
@@ -237,13 +237,13 @@
</td>
</t>
<t t-if="column.type === 'button_group'">
<td t-on-keydown.synthetic="(ev) => this.onCellKeydown(ev, group, record)" class="o_data_cell" t-att-class="getCellClass(column, record)" t-on-click="(ev) => this.onButtonCellClicked(record, column, ev)" tabindex="-1">
<td t-on-keydown.synthetic="(ev) => this.onCellKeydown(ev, group, record)" class="o_data_cell cursor-pointer" t-att-class="getCellClass(column, record)" t-on-click="(ev) => this.onButtonCellClicked(record, column, ev)" tabindex="-1">
<t t-foreach="column.buttons" t-as="button" t-key="button.id">
<ViewButton t-if="!evalModifier(button.modifiers.invisible, record)"
className="button.className"
clickParams="button.clickParams"
defaultRank="button.defaultRank"
disabled="record.isVirtual"
disabled="record.isVirtual || button.disabled"
icon="button.icon"
record="record"
string="button.string"
+1
View File
@@ -203,6 +203,7 @@ export function isNull(value) {
export function processButton(node) {
return {
className: node.getAttribute("class") || "",
disabled: !!node.getAttribute("disabled") || false,
icon: node.getAttribute("icon") || false,
title: node.getAttribute("title") || undefined,
string: node.getAttribute("string") || undefined,
@@ -787,6 +787,26 @@ QUnit.module("Views", (hooks) => {
assert.containsNone(target, "button.btn.btn-link.btn-danger");
});
QUnit.test("list view with disabled button", async function (assert) {
await makeView({
type: "list",
resModel: "foo",
serverData,
arch: `
<tree>
<button name="a" icon="fa-coffee"/>
<button name="b" icon="fa-car" disabled="disabled"/>
</tree>`,
});
assert.ok(
Array.from(target.querySelectorAll("button[name='a']")).every((btn) => !btn.disabled)
);
assert.ok(
Array.from(target.querySelectorAll("button[name='b']")).every((btn) => btn.disabled)
);
});
QUnit.test("list view: action button in controlPanel basic rendering", async function (assert) {
await makeView({
type: "list",