summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-03-01 10:53:03 +0100
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commitf79399bf7720e7a69b95fe2c548208b56b94ce29 (patch)
treec22ece4d8335ae8ad310fa7602cfbad308c6d29b /addons/web/static/src/js/views/basic
parent2bd4497b494e6d3dece46026283cce75beb1da91 (diff)
[FIX] web: parse date(time) values after onchange
Date and Datetime values are stored as moment instances, not strings. This wasn't the case after an onchange, and it thus produced a crash as we tried to call the format method on a string.
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js14
1 files changed, 10 insertions, 4 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 b16bf1e10b0..785cf79775b 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -539,10 +539,10 @@ var BasicModel = AbstractModel.extend({
defs.push(self._fetchNameGets(x2manyList, name));
});
} else if (field.type === 'date') {
- // process date: convert into Date object
+ // process date: convert into a moment instance
record._changes[name] = fieldUtils.parse.date(result[name]);
} else if (field.type === 'datetime') {
- // process datetime: convert into Date object
+ // process datetime: convert into a moment instance
record._changes[name] = fieldUtils.parse.datetime(result[name]);
} else {
record._changes[name] = result[name];
@@ -1042,6 +1042,12 @@ var BasicModel = AbstractModel.extend({
list._changes = [];
}
});
+ } else if (field.type === 'date') {
+ // process data: convert into a moment instance
+ record._changes[name] = fieldUtils.parse.date(val);
+ } else if (field.type === 'datetime') {
+ // process datetime: convert into a moment instance
+ record._changes[name] = fieldUtils.parse.datetime(val);
} else {
record._changes[name] = val;
}
@@ -1265,10 +1271,10 @@ var BasicModel = AbstractModel.extend({
record.data[name] = false;
}
} else if (field.type === 'date') {
- // process data: convert into Date object
+ // process data: convert into a moment instance
record.data[name] = fieldUtils.parse.date(val);
} else if (field.type === 'datetime') {
- // process datetime: convert into Date object
+ // process datetime: convert into a moment instance
record.data[name] = fieldUtils.parse.datetime(val);
}
});