summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-04-04 15:08:00 +0200
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit3ff7ff3e94e4fe34ec09a45fda04f0c8de33cd32 (patch)
tree077d8ba0b7f3ba1c270e1234125d7ce8c89d012e /addons/web/static/src/js/views/basic/basic_model.js
parenta529a928b4a295d5a834bcd8ab9a02433be6ff6a (diff)
[FIX] web: properly evaluate unset numeric values in domain
Before this commit, when a numeric value was not set (for example, a new record with no default_get value), then it was not properly evaluated as 0 in a domain. We also slightly refactored the code so we always use the same method to compute the evaluation context.
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.js11
1 files changed, 10 insertions, 1 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 0642fd6842c..f59cf96a881 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -268,6 +268,8 @@ var BasicModel = AbstractModel.extend({
* @param {boolean} [options.env=false] if true, will only return res_id
* (if record) or res_ids (if list)
* @param {boolean} [options.raw=false] if true, will not follow relations
+ * @param {boolean} [options.noUnsetNumeric=false] if true, will set numeric
+ * values to 0 if not set
* @returns {Object}
*/
get: function (id, options) {
@@ -311,6 +313,13 @@ var BasicModel = AbstractModel.extend({
if (!field) {
continue;
}
+ if (options.noUnsetNumeric) {
+ if (field.type === 'float' ||
+ field.type === 'integer' ||
+ field.type === 'monetary') {
+ element.data[fieldName] = element.data[fieldName] || 0;
+ }
+ }
// get relational datapoint
if (field.type === 'many2one') {
@@ -1792,7 +1801,7 @@ var BasicModel = AbstractModel.extend({
* @returns {Object}
*/
_getEvalContext: function (element) {
- var evalContext = this.get(element.id, {raw: true}).data;
+ var evalContext = this.get(element.id, {raw: true, noUnsetNumeric: true}).data;
evalContext.active_model = element.model;
if (evalContext.id) {
evalContext.active_id = evalContext.id;