From 3dd1c0f87ede01469018f2fadad77b23c789cab8 Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Fri, 14 Jul 2017 15:10:26 +0200 Subject: [FIX] web: undefined group name for group by date: Previously, grouping a list by a non-default time interval (e.g. 'creation date:week') yielded a grouped list of records with undefined group names. --- addons/web/static/src/js/views/basic/basic_model.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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 5fb77204ec7..9613d5fb8be 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -84,8 +84,8 @@ odoo.define('web.BasicModel', function (require) { var AbstractModel = require('web.AbstractModel'); var concurrency = require('web.concurrency'); -var core = require('web.core'); var Context = require('web.Context'); +var core = require('web.core'); var Domain = require('web.Domain'); var fieldUtils = require('web.field_utils'); var session = require('web.session'); @@ -3087,7 +3087,8 @@ var BasicModel = AbstractModel.extend({ lazy: true, }) .then(function (groups) { - var rawGroupBy = list.groupedBy[0].split(':')[0]; + var groupByField = list.groupedBy[0]; + var rawGroupBy = groupByField.split(':')[0]; var previousGroups = _.map(list.data, function (groupID) { return self.localData[groupID]; }); @@ -3098,13 +3099,13 @@ var BasicModel = AbstractModel.extend({ _.each(groups, function (group) { var aggregateValues = {}; _.each(group, function (value, key) { - if (_.contains(fields, key) && key !== list.groupedBy[0]) { + if (_.contains(fields, key) && key !== groupByField) { aggregateValues[key] = value; } }); // When a view is grouped, we need to display the name of each group in // the 'title'. - var value = group[rawGroupBy]; + var value = group[groupByField]; if (list.fields[rawGroupBy].type === "selection") { var choice = _.find(list.fields[rawGroupBy].selection, function (c) { return c[0] === value; -- cgit v1.2.3 From 5f8dea490acd1812cb7d920ef793cf414014e296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 17 Jul 2017 15:50:43 +0200 Subject: [FIX] web: properly display id in some cases When a one2many is set through an onchange, the web client did not set the id field properly. Because of that, it could not be displayed in a list. This is due to the fact that the id is given in the command like this: [1, 53, {...}] Here, the command is 1 (update), then 53 (id), then some values, which do not have the id. So, in this specific case, we assumed that all the new values were in the object, even though we properly set the res_id property. We fix this issue at the root: in the _makeDataPoint method, we make sure that no datapoint can be created with a res_id and without the corresponding id key. Note that this issue was not found in a standard installation of Odoo (but it may be present somewhere), but in some custom code. It is rare to actually use the id field in a view, but in this case, we had a many2many in kanban view, and the id was used to format the url of an image. --- addons/web/static/src/js/views/basic/basic_model.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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 9613d5fb8be..c95f829af71 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2656,8 +2656,14 @@ var BasicModel = AbstractModel.extend({ var type = params.type || ('domain' in params && 'list') || 'record'; var res_id, value; var res_ids = params.res_ids || []; + var data = params.data || (type === 'record' ? {} : []); if (type === 'record') { - res_id = params.res_id || (params.data && params.data.id) || _.uniqueId('virtual_'); + res_id = params.res_id || (params.data && params.data.id); + if (res_id) { + data.id = res_id; + } else { + res_id = _.uniqueId('virtual_'); + } } else { var isValueArray = params.value instanceof Array; res_id = isValueArray ? params.value[0] : undefined; @@ -2675,7 +2681,7 @@ var BasicModel = AbstractModel.extend({ aggregateValues: params.aggregateValues || {}, context: params.context || {}, count: params.count || res_ids.length, - data: params.data || (type === 'record' ? {} : []), + data: data, domain: params.domain || [], fields: fields, fieldsInfo: params.fieldsInfo, -- cgit v1.2.3 From bce3defc8cd2c0c40e40d7b6cfc58159000ded65 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Mon, 3 Jul 2017 10:46:10 +0200 Subject: [FIX] web: fix calendar server values parsing The record data given to fullCalendar to use in the renderEvent function was not parsed like it is in basic model for example. As a result, date(time) fields were string rather than moment objects, which was triggering the crash that started this commit. --- .../web/static/src/js/views/basic/basic_model.js | 25 ---------------------- 1 file changed, 25 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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 c95f829af71..eead1b0aaed 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -87,7 +87,6 @@ var concurrency = require('web.concurrency'); var Context = require('web.Context'); var core = require('web.core'); var Domain = require('web.Domain'); -var fieldUtils = require('web.field_utils'); var session = require('web.session'); var _t = core._t; @@ -2946,30 +2945,6 @@ var BasicModel = AbstractModel.extend({ } }); }, - /** - * Processes date(time) and selection field values sent by the server. - * Converts data(time) values to moment instances. - * Converts false values of selection fields to 0 if 0 is a valid key, - * because the server doesn't make a distinction between false and 0, and - * always sends false when value is 0. - * - * @param {Object} field the field description - * @param {*} value - * @returns {*} the processed value - */ - _parseServerValue: function (field, value) { - if (field.type === 'date' || field.type === 'datetime') { - // process date(time): convert into a moment instance - value = fieldUtils.parse[field.type](value, field, {isUTC: true}); - } else if (field.type === 'selection' && value === false) { - // process selection: convert false to 0, if 0 is a valid key - var hasKey0 = _.find(field.selection, function (option) { - return option[0] === 0; - }); - value = hasKey0 ? 0 : value; - } - return value; - }, /** * This method is quite important: it is supposed to perform the /onchange * rpc and apply the result. -- cgit v1.2.3 From efd158523438cebd96f9f2e7243873f222a97fea Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Tue, 18 Jul 2017 11:33:09 +0200 Subject: [FIX] web: fix action context Previously, we had to filter the context values to exclude some erroneous values we propagated earlier. This commit removes the earlier propagation of wrong values (the current record context when executing an action) and thus also removes the filtering of those values, which was actually removing useful values from the action context. The bug could be seen by following these steps: - Install crm and sale - Go to My Pipeline - Open an opportunity which has a customer set - Click on "New Quotation" action button - See that the customer is not set on the new quotation, it should be set by the default_partner_id value in the action context --- addons/web/static/src/js/views/basic/basic_model.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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 eead1b0aaed..75a0ad02971 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -2369,8 +2369,8 @@ var BasicModel = AbstractModel.extend({ * if given, this field's context is added to the context, instead of * the element's context (except if options.full is true) * @param {boolean} [options.full=false] - * if true and fieldName given in options, the element's context - * is added to the context + * if true or nor fieldName or additionalContext given in options, + * the element's context is added to the context * @returns {Object} the evaluated context */ _getContext: function (element, options) { @@ -2378,7 +2378,7 @@ var BasicModel = AbstractModel.extend({ var context = new Context(session.user_context); context.set_eval_context(this._getEvalContext(element)); - if (options.full || !options.fieldName) { + if (options.full || !(options.fieldName || options.additionalContext)) { context.add(element.context); } if (options.fieldName) { -- cgit v1.2.3