From 18c3dbc2e990531bf2ed411580a4e6a8ca0954b3 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 5 May 2017 10:24:39 +0200 Subject: [FIX] web: FieldMany2Many with editable lists: save changes This rev. fixes 2 issues about many2many fields displayed with an editable list view, occuring when the user edited some values in the list. First, the many2many field was re-rendered each time one of its sub-widgets triggered a 'field_changed' event, and thus the row the user was editing was no more in edition and the focused field was no more focused. This was quite annoying. Second, when the user saved changes made in the editable list view, only a command 6 (REPLACE_ALL) was sent, so updates of subrecords were never saved. --- addons/web/static/src/js/views/basic/basic_model.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic') 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 cde2d2479ac..17cb4d277c2 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1847,8 +1847,17 @@ var BasicModel = AbstractModel.extend({ // of a 'delete' and a 'link' commands with the exact diff // because 1) performance-wise it doesn't change anything // and 2) to guard against concurrent updates (policy: force - // an complete override of the actual value of the m2m) + // a complete override of the actual value of the m2m) commands[fieldName].push(x2ManyCommands.replace_with(relIds)); + // generate update commands for records that have been + // updated (it may happen with editable lists) + _.each(relData, function (relRecord) { + if (!_.isEmpty(relRecord._changes)) { + var changes = self._generateChanges(relRecord); + var command = x2ManyCommands.update(relRecord.res_id, changes); + commands[fieldName].push(command); + } + }); } else if (type === 'one2many') { var removedIds = _.difference(list.res_ids, relIds); var addedIds = _.difference(relIds, list.res_ids); -- cgit v1.2.3