diff options
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/form_common.js | 13 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/form_relational_widgets.js | 12 |
2 files changed, 22 insertions, 3 deletions
diff --git a/addons/web/static/src/js/views/form_common.js b/addons/web/static/src/js/views/form_common.js index 273da34f678..24c64aad7a4 100644 --- a/addons/web/static/src/js/views/form_common.js +++ b/addons/web/static/src/js/views/form_common.js @@ -715,7 +715,7 @@ var AbstractField = FormWidget.extend(FieldInterface, { } }, _toggle_label: function() { - var empty = this.get('effective_readonly') && this.is_false(); + var empty = this.get('effective_readonly') && !this.is_set(); this.$label.toggleClass('o_form_label_empty', empty).toggleClass('o_form_label_false', this.get('effective_readonly') && this.get('value') === false); this.$el.toggleClass('o_form_field_empty', empty); }, @@ -754,10 +754,21 @@ var AbstractField = FormWidget.extend(FieldInterface, { /** * Method useful to implement to ease validity testing. Must return true if the current * value is similar to false in OpenERP. + * Used at write time, in particular when the field is required */ is_false: function() { return this.get('value') === false; }, + + /** + * Method called at rendering time to determine if the field should be + * displayed (non-empty) or not (empty) + * We test the same thing as is_false but with different semantics + */ + is_set: function() { + return !this.is_false(); + }, + _check_css_flags: function() { var show_translate = (!this.get('effective_readonly') && this.field_manager.get('actual_mode') !== "create"); this.$translate.toggleClass('o_translate_active', !!show_translate); diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index 2517b3c57b8..e8e9c450c3c 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -346,8 +346,8 @@ var FieldMany2One = common.AbstractField.extend(common.CompletionFieldMixin, com if (!this.get("effective_readonly")) { this.$input.val(noValue ? "" : (str.split("\n")[0].trim() || $(data.noDisplayContent).text())); this.current_display = this.$input.val(); - this.$follow_button.toggle(!this.is_false()); - this.$el.toggleClass('o_with_button', !!this.$follow_button && this.$follow_button.length > 0 && !this.is_false()); + this.$follow_button.toggle(this.is_set()); + this.$el.toggleClass('o_with_button', !!this.$follow_button && this.$follow_button.length > 0 && this.is_set()); } else { this.$el.html(noValue ? "" : (_.escape(str.trim()).split("\n").join("<br/>") || data.noDisplayContent)); // Define callback to perform when clicking on the field @@ -872,6 +872,10 @@ var FieldX2Many = AbstractManyField.extend({ is_false: function() { return _(this.dataset.ids).isEmpty(); }, + is_set: function() { + // always consider that field is "set" hence displayed + return true; + }, }); var X2ManyDataSet = data.BufferedDataSet.extend({ @@ -1718,6 +1722,10 @@ var FieldMany2ManyCheckBoxes = AbstractManyField.extend(common.ReinitializeField is_false: function() { return false; }, + is_set: function() { + // always consider that field is "set" hence displayed + return true; + }, }); core.form_widget_registry |
