From c22b796375f8891c81d453307b72b80496282e36 Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Tue, 7 Mar 2023 11:48:44 +0000 Subject: [PATCH] [FIX] web: StateSelectionField display Label only in list view Since commit 17a24020acb2d492bb09a3a758c9ee3fd1f765a2, StateSelectionField displays its label in all views. This was an error. It should only display its label in list views. closes odoo/odoo#114538 Signed-off-by: Aaron Bohy (aab) --- .../project_state_selection/project_state_selection.js | 4 ---- addons/project/views/project_views.xml | 2 +- .../fields/state_selection/state_selection_field.js | 9 +++------ .../fields/state_selection/state_selection_field.xml | 4 ++-- .../tests/views/fields/state_selection_field_tests.js | 1 + 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/addons/project/static/src/components/project_state_selection/project_state_selection.js b/addons/project/static/src/components/project_state_selection/project_state_selection.js index cffef1e1fb7..5f6460b9eac 100644 --- a/addons/project/static/src/components/project_state_selection/project_state_selection.js +++ b/addons/project/static/src/components/project_state_selection/project_state_selection.js @@ -26,10 +26,6 @@ export class ProjectStateSelectionField extends StateSelectionField { export const projectStateSelectionField = { ...stateSelectionField, component: ProjectStateSelectionField, - extractProps: (fieldInfo) => ({ - ...stateSelectionField.extractProps(fieldInfo), - hideLabel: !!fieldInfo.options.hideLabel, - }), }; registry.category("fields").add("kanban.project_state_selection", projectStateSelectionField); diff --git a/addons/project/views/project_views.xml b/addons/project/views/project_views.xml index 603c8febdae..5f062027ec9 100644 --- a/addons/project/views/project_views.xml +++ b/addons/project/views/project_views.xml @@ -921,7 +921,7 @@
- +
diff --git a/addons/web/static/src/views/fields/state_selection/state_selection_field.js b/addons/web/static/src/views/fields/state_selection/state_selection_field.js index d1c33b8273c..284fa65f387 100644 --- a/addons/web/static/src/views/fields/state_selection/state_selection_field.js +++ b/addons/web/static/src/views/fields/state_selection/state_selection_field.js @@ -18,11 +18,11 @@ export class StateSelectionField extends Component { }; static props = { ...standardFieldProps, - hideLabel: { type: Boolean, optional: true }, + showLabel: { type: Boolean, optional: true }, withCommand: { type: Boolean, optional: true }, }; static defaultProps = { - hideLabel: false, + showLabel: true, }; setup() { @@ -63,9 +63,6 @@ export class StateSelectionField extends Component { } return formatSelection(this.currentValue, { selection: this.options }); } - get showLabel() { - return !this.props.hideLabel; - } get isReadonly() { return this.props.record.isReadonly(this.props.name); } @@ -92,7 +89,7 @@ export const stateSelectionField = { displayName: _lt("Label Selection"), supportedTypes: ["selection"], extractProps: ({ options, viewType }) => ({ - hideLabel: !!options.hide_label && viewType === "list", + showLabel: viewType === "list" && !options.hide_label, withCommand: viewType === "form", }), }; diff --git a/addons/web/static/src/views/fields/state_selection/state_selection_field.xml b/addons/web/static/src/views/fields/state_selection/state_selection_field.xml index 2f343e74f69..b4c19933d5a 100644 --- a/addons/web/static/src/views/fields/state_selection/state_selection_field.xml +++ b/addons/web/static/src/views/fields/state_selection/state_selection_field.xml @@ -5,7 +5,7 @@ @@ -13,7 +13,7 @@
- +
diff --git a/addons/web/static/tests/views/fields/state_selection_field_tests.js b/addons/web/static/tests/views/fields/state_selection_field_tests.js index 1da2740c221..ccf2f7b44d9 100644 --- a/addons/web/static/tests/views/fields/state_selection_field_tests.js +++ b/addons/web/static/tests/views/fields/state_selection_field_tests.js @@ -532,6 +532,7 @@ QUnit.module("Fields", (hooks) => { return performRPC(route, args); }, }); + assert.containsNone(target, ".o_status_label"); await click(target, ".o_field_state_selection button"); const doneItem = target.querySelectorAll(".dropdown-item")[2]; // item "done";