diff options
| author | Martin Geubelle <mge@odoo.com> | 2017-06-21 16:43:21 +0200 |
|---|---|---|
| committer | Martin Geubelle <mge@odoo.com> | 2017-06-22 10:52:26 +0200 |
| commit | c62a4edcb04fb1e3d65dea056123cece72425b7e (patch) | |
| tree | ea8a615d6314998690c2debed6047c57222695b5 /addons/web/static/src | |
| parent | 3de0715f12d1a965d444f2d1cc816ca3d740a839 (diff) | |
[FIX] web: set 0 as default value for numeric fields
When creating a new record, the numeric field default value should be 0 in order
to avoid manually setting mandatory fields to 0.
This behaviour has been removed with the new views but one wants to restore it.
The `mockRead` function has also been adapted in this commit because the server
returns 0 for unset numeric fields.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 1ace44be50f..716624f368b 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2198,12 +2198,6 @@ var BasicModel = AbstractModel.extend({ if (!field || field.name === 'id') { continue; } - if (field.type === 'float' || - field.type === 'integer' || - field.type === 'monetary') { - context[fieldName] = context[fieldName] || 0; - continue; - } if (field.type === 'date' || field.type === 'datetime') { if (context[fieldName]) { context[fieldName] = JSON.parse(JSON.stringify(context[fieldName])); @@ -2449,7 +2443,11 @@ var BasicModel = AbstractModel.extend({ var fieldName = fieldNames[i]; if (!(fieldName in result)) { var field = params.fields[fieldName]; - if (field.type === 'one2many' || field.type === 'many2many') { + if (field.type === 'float' || + field.type === 'integer' || + field.type === 'monetary') { + result[fieldName] = 0; + } else if (field.type === 'one2many' || field.type === 'many2many') { result[fieldName] = []; } else { result[fieldName] = null; |
