[FIX] web: Fix readonly modifier not working with clickable option on statusbar field
Before this commit: The readonly readonly modifier of the statusbar field was not taken into account when the "clickable" option was set. After this commit: Even if the "clickable" option is set to true, if a readonly modifier is set, it will prevent (or not) changing the stage of a status bar. closes odoo/odoo#145766 Opw: 3222998 X-original-commit: 9e1d01bc44e5e90ed2b809cfadbd05a5793b3c07 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Bastien Fafchamps (bafa) <bafa@odoo.com>
This commit is contained in:
@@ -131,7 +131,7 @@ export class StatusBarField extends Component {
|
||||
{
|
||||
category: "smart_action",
|
||||
hotkey: "alt+shift+x",
|
||||
isAvailable: () => !this.props.readonly && !this.props.isDisabled,
|
||||
isAvailable: () => !this.props.isDisabled,
|
||||
}
|
||||
);
|
||||
useCommand(
|
||||
@@ -145,9 +145,7 @@ export class StatusBarField extends Component {
|
||||
category: "smart_action",
|
||||
hotkey: "alt+x",
|
||||
isAvailable: () =>
|
||||
!this.props.readonly &&
|
||||
!this.props.isDisabled &&
|
||||
!this.getAllItems().at(-1).isSelected,
|
||||
!this.props.isDisabled && !this.getAllItems().at(-1).isSelected,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -346,7 +344,7 @@ export const statusBarField = {
|
||||
supportedTypes: ["many2one", "selection"],
|
||||
isEmpty: (record, fieldName) => !record.data[fieldName],
|
||||
extractProps: ({ attrs, options, viewType }, dynamicInfo) => ({
|
||||
isDisabled: !options.clickable,
|
||||
isDisabled: !options.clickable || dynamicInfo.readonly,
|
||||
visibleSelection: attrs.statusbar_visible?.trim().split(/\s*,\s*/g),
|
||||
withCommand: viewType === "form",
|
||||
foldField: options.fold_field,
|
||||
|
||||
@@ -707,4 +707,65 @@ QUnit.module("Fields", (hooks) => {
|
||||
assert.verifySteps(["search_read"]);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"clickable statusbar with readonly modifier set to false is editable",
|
||||
async function (assert) {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 2,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<header>
|
||||
<field name="product_id" widget="statusbar" options="{'clickable': true}" readonly="False"/>
|
||||
</header>
|
||||
</form>`,
|
||||
});
|
||||
assert.containsN(target, ".o_statusbar_status button:visible", 2);
|
||||
assert.containsNone(
|
||||
target,
|
||||
".o_statusbar_status button[disabled][aria-checked='false']:visible"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"clickable statusbar with readonly modifier set to true is not editable",
|
||||
async function (assert) {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 2,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<header>
|
||||
<field name="product_id" widget="statusbar" options="{'clickable': true}" readonly="True"/>
|
||||
</header>
|
||||
</form>`,
|
||||
});
|
||||
assert.containsN(target, ".o_statusbar_status button[disabled]:visible", 2);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"non-clickable statusbar with readonly modifier set to false is not editable",
|
||||
async function (assert) {
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
resId: 2,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<header>
|
||||
<field name="product_id" widget="statusbar" options="{'clickable': false}" readonly="False"/>
|
||||
</header>
|
||||
</form>`,
|
||||
});
|
||||
assert.containsN(target, ".o_statusbar_status button[disabled]:visible", 2);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user