[FIX] web: mock server was replacing "falsy" values with default ones

When setting a field value to "0", the mock server was replacing it
with the field default value as "0" is a falsy value. Now it only
adds the default values where there is no value at all, as expected.
This commit is contained in:
qsm-odoo
2017-04-11 19:44:38 +02:00
committed by Aaron Bohy
parent c24d1f615c
commit a52690c26c
@@ -17,7 +17,6 @@ var MockServer = Class.extend({
*/
init: function (data, options) {
this.data = data;
for (var modelName in this.data) {
var model = this.data[modelName];
if (!('id' in model.fields)) {
@@ -129,8 +128,11 @@ var MockServer = Class.extend({
if (fieldName === 'id') {
continue;
}
if (model.fields[fieldName].type !== 'boolean' || record[fieldName] !== false) {
record[fieldName] = record[fieldName] || model.fields[fieldName].default;
if (!(fieldName in record)) {
record[fieldName] = model.fields[fieldName].default;
if (model.fields[fieldName].type === 'boolean') {
record[fieldName] = record[fieldName] || false;
}
}
}
},