From e17dd719cfa68de569c4ebdc6ac51d9a76bab7a3 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Tue, 14 Mar 2017 10:52:02 +0100 Subject: [ADD] web: add monetary field documentation --- addons/web/static/src/js/fields/basic_fields.js | 36 +++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'addons/web/static/src/js/fields/basic_fields.js') 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({ -- cgit v1.2.3