From 3ff7ff3e94e4fe34ec09a45fda04f0c8de33cd32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 4 Apr 2017 15:08:00 +0200 Subject: [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. --- .../static/src/js/views/basic/basic_renderer.js | 38 ---------------------- 1 file changed, 38 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js') diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js index 2aa4479648b..1db0718545e 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -51,44 +51,6 @@ return AbstractRenderer.extend({ } }); }, - /** - * Helper method, used to get an object with the 'raw' field values. It is - * important when we want to evaluate if a record matches a given domain. - * - * A basic model record is a tree structure, but we sometimes need 'pure' - * data, so for example, [1,4] for the value of a one2many, not - * [{Object}, {Object}]. - * - * @param {Object} record - * @returns {Object} - */ - _getFieldValues: function (record) { - var result = {}; - _.each(record.getFieldNames(), function (name) { - var field = record.fields[name]; - var value = record.data[name]; - result[name] = value; - if (!value) { - return; - } - else if (field.type === 'many2one') { - result[name] = value.data ? value.data.id || false : false; - } - else if (field.type === 'one2many' || field.type === 'many2many') { - if (value) { - result[name] = _.pluck(value.data, 'res_id'); - } else { - result[name] = []; - } - } - else if (field.type === 'boolean') { - // we want an explicit false value, not null if it is unset - result[name] = value || false; - } - }); - result.id = record.data.id; - return result; - }, /** * Render the view * -- cgit v1.2.3