diff options
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 | 18 |
1 files changed, 15 insertions, 3 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 5b6eb35b4ac..965237e1df1 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1307,13 +1307,25 @@ var BasicModel = AbstractModel.extend({ record._changes[name] = list.id; var shouldLoad = false; list._changes = list._changes || []; + + // save it in case of a [5] which will remove the _changes + var oldChanges = list._changes; _.each(val, function (command) { - var rec; + var rec, recID; if (command[0] === 0 || command[0] === 1) { // CREATE or UPDATE + if (command[0] === 0 && command[1]) { + // updating an existing (virtual) record + var previousChange = _.find(oldChanges, function (operation) { + var child = self.localData[operation.id]; + return child && (child.res_id === command[1]); + }); + recID = previousChange && previousChange.id; + rec = self.localData[recID]; + } if (command[0] === 1 && command[1]) { // updating an existing record - var recID = _.find(list.data, function (childID) { + recID = _.find(list.data, function (childID) { var child = self.localData[childID]; return child.res_id === command[1]; }); @@ -1327,7 +1339,7 @@ var BasicModel = AbstractModel.extend({ modelName: list.model, parentID: list.id, viewType: list.viewType, - ref: command[1], + ref: command[1], }; if (command[0] === 1) { params.res_id = command[1]; |
