From 15a032e84abf74d5ada99c3c0dce6078bf72c766 Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Wed, 24 Aug 2022 13:46:03 +0000 Subject: [PATCH] [FIX] web: placeholder in required SelectionField This commit adds the possibility of having a placeholder in a required SelectionField. Solution: We always add a false option with the placeholder but it is "display:none" if the field is required. How to reproduce: - create a new record in a form view with a required selection field Result before: The first option of the selection field will be selected Result after: The placeholder of the selection field will be selected When editing the selection field, the selection field does not propose the placeholder. closes odoo/odoo#98823 Signed-off-by: Aaron Bohy (aab) --- .../font_selection/font_selection_field.js | 6 +-- .../font_selection/font_selection_field.xml | 6 +++ .../views/fields/selection/selection_field.js | 13 ++--- .../fields/selection/selection_field.xml | 6 +++ .../views/fields/selection_field_tests.js | 54 +++++++++---------- 5 files changed, 42 insertions(+), 43 deletions(-) diff --git a/addons/web/static/src/views/fields/font_selection/font_selection_field.js b/addons/web/static/src/views/fields/font_selection/font_selection_field.js index 6b2024f8677..c27798b1081 100644 --- a/addons/web/static/src/views/fields/font_selection/font_selection_field.js +++ b/addons/web/static/src/views/fields/font_selection/font_selection_field.js @@ -9,13 +9,9 @@ const { Component } = owl; export class FontSelectionField extends Component { get options() { - const options = this.props.record.fields[this.props.name].selection.filter( + return this.props.record.fields[this.props.name].selection.filter( (option) => option[0] !== false && option[1] !== "" ); - if (!this.isRequired) { - options.unshift([false, this.props.placeholder || ""]); - } - return options; } get isRequired() { return this.props.record.isRequired(this.props.name); diff --git a/addons/web/static/src/views/fields/font_selection/font_selection_field.xml b/addons/web/static/src/views/fields/font_selection/font_selection_field.xml index b079da1164a..6699f82b4e8 100644 --- a/addons/web/static/src/views/fields/font_selection/font_selection_field.xml +++ b/addons/web/static/src/views/fields/font_selection/font_selection_field.xml @@ -7,6 +7,12 @@ +