summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-09-21 18:52:56 +0200
committerChristophe Simonis <chs@odoo.com>2017-09-21 18:52:56 +0200
commit4b455098f8cefa5122479a5a84fa07c2330e7a66 (patch)
tree43d625a9e37a5d9c07780f8116bf0247fb693fe0 /addons/web/static/src/js/views/basic/basic_model.js
parentf53e65c356a5d43d2b5b50dc509ee70e0df30ba5 (diff)
parent5c51a0ad4d6bfab6427949ffe61650196798846a (diff)
[MERGE] forward port branch saas-18 up to 5c51a0ad4d6
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.js21
1 files changed, 17 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 5b6eb35b4ac..276fd4df82b 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -769,7 +769,7 @@ var BasicModel = AbstractModel.extend({
removeLine: function (elementID) {
var record = this.localData[elementID];
var parent = this.localData[record.parentID];
- if (parent.parentID) {
+ if (parent.static) {
// x2Many case: the new record has been stored in _changes, as a
// command so we remove the command(s) related to that record
parent._changes = _.filter(parent._changes, function (change) {
@@ -778,6 +778,7 @@ var BasicModel = AbstractModel.extend({
} else {
// main list view case: the new record is in data
parent.data = _.without(parent.data, elementID);
+ parent.count--;
}
},
/**
@@ -1307,13 +1308,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 +1340,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];