diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2019-11-04 15:25:17 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-04-17 13:56:08 +0000 |
| commit | 4c1feefd13b6b63798be89005c60baff1d677567 (patch) | |
| tree | 834e19c59aa42f55b954cf4f4d892945bd75284f /addons/web/static/src/js/fields | |
| parent | 7ace5a986a042ced675fb821bbf527d2d69ca614 (diff) | |
[IMP] web: Numeric fields can be non-formatted
This commit introduces a new option in fields inheriting from type Numeric
which is `format`.
By default, Numeric fields are formatted according to their subtypes and locale
Adding, in a view, the option format set to a falsy value
will prevent the field's value from being formatted.
```
<field name="int_field" options="{\'format\': false}"/>
```
Task 2050119
Diffstat (limited to 'addons/web/static/src/js/fields')
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 1f8362d090e..2ec474bc2b3 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -365,6 +365,16 @@ var InputField = DebouncedField.extend({ var NumericField = InputField.extend({ tagName: 'span', + /** + * @override + */ + init() { + this._super.apply(this, arguments); + this.shouldFormat = Boolean( + JSON.parse('format' in this.nodeOptions ? this.nodeOptions.format : true) + ); + }, + //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- @@ -427,7 +437,7 @@ var NumericField = InputField.extend({ * @private */ _formatValue: function (value) { - if (this.mode === 'edit' && this.nodeOptions.type === 'number') { + if (!this.shouldFormat || (this.mode === 'edit' && this.nodeOptions.type === 'number')) { return value; } return this._super.apply(this, arguments); |
