diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-05-05 10:24:39 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-05-05 13:31:48 +0200 |
| commit | 18c3dbc2e990531bf2ed411580a4e6a8ca0954b3 (patch) | |
| tree | 4baa63c2417a0050164c0a752cf8dfc389bdf984 /addons/web/static/src/js/views/basic/basic_model.js | |
| parent | e8f9bb683d958f0a7efa1e42a53633b72150c32f (diff) | |
[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.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 11 |
1 files changed, 10 insertions, 1 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 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); |
