diff options
| author | David Monjoie <dmo@odoo.com> | 2017-03-14 10:52:02 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | e17dd719cfa68de569c4ebdc6ac51d9a76bab7a3 (patch) | |
| tree | 8328efddc0a7e590edee7bce4bf0ac31468a18ba /addons/web/static/src/js | |
| parent | 4eb2245c5d47d04e2177d4aa4d8edd265898dca3 (diff) | |
[ADD] web: add monetary field documentation
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index d08c628c164..a5596648251 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -258,16 +258,36 @@ var FieldDateTime = FieldDate.extend({ var FieldMonetary = InputField.extend({ className: 'o_list_number', supportedFieldTypes: ['float', 'monetary'], - // FieldMonetary overrides _formatValue to ensure that the format_monetary - // method is used. This allows this widget to be used with other field - // types, such as float. + + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + /** + * For monetary fields, 0 is a valid value. + * + * @override + */ + isSet: function () { + return this.value === 0 || this._super.apply(this, arguments); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * FieldMonetary overrides _formatValue to ensure that the format_monetary + * method is used. This allows this widget to be used with other field + * types, such as float. + * + * @override + * @private + * @param {float} value + */ _formatValue: function (value) { - var options = _.extend({}, this.nodeOptions, { data: this.recordData }); - return field_utils.format.monetary(value, this.field, options); + return field_utils.format.monetary(value, this.field, this.record_data, this.node_options); }, - isSet: function () { - return this.value !== false; - } }); var FieldBoolean = AbstractField.extend({ |
