summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2019-09-27 14:46:35 +0000
committerJulien Mougenot <jum@odoo.com>2019-09-30 12:53:18 +0000
commit652414ca4e42c0f0ece0b70e88a1a74c014b0dcd (patch)
tree6b7eba19117da90b5c6c347545004b620b8a2fa2 /addons/web/static/src/js
parent53bb1387b58937f2b6b84768f59e6982f7847517 (diff)
[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) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js10
-rw-r--r--addons/web/static/src/js/views/list/list_controller.js2
-rw-r--r--addons/web/static/src/js/views/list/list_model.js5
3 files changed, 13 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 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
diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js
index 611079ca3d5..fbd5e4a2af0 100644
--- a/addons/web/static/src/js/views/list/list_controller.js
+++ b/addons/web/static/src/js/views/list/list_controller.js
@@ -410,7 +410,7 @@ var ListController = BasicController.extend({
if (validRecordIds.length > 0) {
const dialogOptions = {
confirm_callback: () => {
- this.model.saveRecords(recordId, validRecordIds, fieldName)
+ this.model.saveRecords(this.handle, recordId, validRecordIds, fieldName)
.then(async () => {
this._updateButtons('readonly');
const state = this.model.get(this.handle);
diff --git a/addons/web/static/src/js/views/list/list_model.js b/addons/web/static/src/js/views/list/list_model.js
index 65526346c8e..9ba0b473a5a 100644
--- a/addons/web/static/src/js/views/list/list_model.js
+++ b/addons/web/static/src/js/views/list/list_model.js
@@ -37,15 +37,16 @@ odoo.define('web.ListModel', function (require) {
* For a list of records, performs a write with all changes and fetches
* all data.
*
+ * @param {string} listDatapointId id of the parent list
* @param {string} referenceRecordId the record datapoint used to
* generate the changes to apply to recordIds
* @param {string[]} recordIds a list of record datapoint ids
* @param {string} fieldName the field to write
*/
- saveRecords: function (referenceRecordId, recordIds, fieldName) {
+ saveRecords: function (listDatapointId, referenceRecordId, recordIds, fieldName) {
var self = this;
var referenceRecord = this.localData[referenceRecordId];
- var list = this.localData[referenceRecord.parentID];
+ var list = this.localData[listDatapointId];
// generate all record values to ensure that we'll write something
// (e.g. 2 records selected, edit a many2one in the first one, but
// reset same value, we still want to save this value on the other