From c62a4edcb04fb1e3d65dea056123cece72425b7e Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Wed, 21 Jun 2017 16:43:21 +0200 Subject: [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. --- addons/web/static/src/js/views/basic/basic_model.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'addons/web/static/src/js/views/basic') 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; -- cgit v1.2.3