From 1787ff0b52ab409efd91c4888d8d5fd62cbe7981 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 24 Sep 2019 19:56:04 +0000 Subject: [FIX] web: don't allow to aggregate date(time) Go to Accounting > Accounting > General ledger. The view is grouped by account. There is a layout issue as the first column (date) is positionned after the group names, leaving a large blank space. This is because the date field is considered as an aggregated field (for sorting purpose, in python), but the JS can't (and we don't want to) display it. This rev. ensures that such field types are completely ignored by the JS, s.t. they do not impact the layout. closes odoo/odoo#37113 Signed-off-by: VincentSchippefilt --- addons/web/static/src/js/views/basic/basic_model.js | 8 ++++++-- 1 file changed, 6 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 4b4d02c2755..ce8d028d0af 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -94,6 +94,9 @@ var viewUtils = require('web.viewUtils'); var _t = core._t; +// field types that can be aggregated in grouped views +const AGGREGATABLE_TYPES = ['float', 'integer', 'monetary']; + var x2ManyCommands = { // (0, virtualID, {values}) CREATE: 0, @@ -4451,8 +4454,9 @@ var BasicModel = AbstractModel.extend({ _.each(groups, function (group) { var aggregateValues = {}; _.each(group, function (value, key) { - if (_.contains(fields, key) && key !== groupByField) { - aggregateValues[key] = value; + if (_.contains(fields, key) && key !== groupByField && + AGGREGATABLE_TYPES.includes(list.fields[key].type)) { + aggregateValues[key] = value; } }); // When a view is grouped, we need to display the name of each group in -- cgit v1.2.3 From 652414ca4e42c0f0ece0b70e88a1a74c014b0dcd Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Fri, 27 Sep 2019 14:46:35 +0000 Subject: [FIX] web: grouped list multi edit with m2m Before this commit, m2m fields were not updated when multi editing in a grouped list. Now, the fields are updated no matter how many levels of groupBys are applied to the list. Part of task 2078807 closes odoo/odoo#37589 Signed-off-by: Aaron Bohy (aab) --- addons/web/static/src/js/views/basic/basic_model.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (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 ce8d028d0af..d4e966440cb 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3356,7 +3356,15 @@ var BasicModel = AbstractModel.extend({ var viewType = view ? view.type : fieldInfo.viewType; var toFetch = {}; - _.each(list.data, function (dataPoint) { + + // flattens the list.data ids in a grouped case + let dataPointIds = list.data; + for (let i = 0; i < list.groupedBy.length; i++) { + dataPointIds = dataPointIds.reduce((acc, groupId) => + acc.concat(this.localData[groupId].data), []); + } + + dataPointIds.forEach(function (dataPoint) { var record = self.localData[dataPoint]; if (typeof record.data[fieldName] === 'string'){ // in this case, the value is a local ID, which means that the -- cgit v1.2.3