diff options
| author | Mohammed Shekha <msh@odoo.com> | 2020-01-16 13:48:20 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-01-27 09:01:19 +0000 |
| commit | 23878ee11ab121bb2d753e64c1d631ba2b85f6e0 (patch) | |
| tree | 9d60321392c1989a0c16204657951887918bf892 /addons/web/static/src | |
| parent | ea9bbdbe30f3394d63301179f51c5ef9e962e91b (diff) | |
[IMP] web: always display statusbar widget
By default, in readonly, unset field widgets (and their labels) are
not displayed. However, we would like the statusbar widget to be
always displayed (even when it is not set).
This commit introduces a new method 'isEmpty' on AbstractField, and
uses it (instead of isSet) to determine whether or not a field should
be hidden. By default, it uses isSet, so that it doesn't change
anything for the other fields, and we override it in statusbar to
always return false.
There was a need to make the distinction with isSet, as this one is
used to determine if a record can be saved (if the field is required,
and isSet returns false, it can't be).
task-2172272
closes odoo/odoo#43419
Related: odoo/enterprise#7929
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/fields/abstract_field.js | 10 | ||||
| -rw-r--r-- | addons/web/static/src/js/fields/relational_fields.js | 15 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_renderer.js | 2 |
3 files changed, 26 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index e0b71f088ad..9fb677d42a0 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -259,6 +259,16 @@ var AbstractField = Widget.extend({ return $(); }, /** + * Returns whether or not the field is empty and can thus be hidden. This + * method is typically called when the widget is in readonly, to hide it + * (and its label) if it is empty. + * + * @returns {boolean} + */ + isEmpty: function () { + return !this.isSet(); + }, + /** * Returns true iff the widget has a visible element that can take the focus * * @returns {boolean} diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 500ebf1f609..0bf264aca1d 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -2722,6 +2722,21 @@ var FieldStatus = AbstractField.extend({ }, //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + /** + * Returns false to force the statusbar to be always visible (even the field + * it not set). + * + * @override + * @returns {boolean} always false + */ + isEmpty: function () { + return false; + }, + + //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js index 8af8540dd57..07edeae343a 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -662,7 +662,7 @@ var BasicRenderer = AbstractRenderer.extend({ element.$el.toggleClass('o_field_empty', !!( record.data.id && (modifiers.readonly || mode === 'readonly') && - !element.widget.isSet() + element.widget.isEmpty() )); }, keepBaseMode: !!options.keepBaseMode, |
