diff options
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 18 |
1 files changed, 10 insertions, 8 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 d897a74c696..716624f368b 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1399,7 +1399,8 @@ var BasicModel = AbstractModel.extend({ * @param {string} [optinos.viewType] the type of view for which the record * is fetched (usefull to load the adequate fields), by defaults, uses * record.viewType - * @returns {Deferred -> Object} resolves to the record + * @returns {Deferred -> Object} resolves to the record or is rejected in + * case no id given were valid ids */ _fetchRecord: function (record, options) { var self = this; @@ -1412,6 +1413,9 @@ var BasicModel = AbstractModel.extend({ context: _.extend({}, record.context, {bin_size: true}), }) .then(function (result) { + if (result.length === 0) { + return $.Deferred().reject(); + } result = result[0]; record.data = _.extend({}, record.data, result); }) @@ -2194,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])); @@ -2445,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; |
