summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-05-29 20:00:31 +0200
committerChristophe Simonis <chs@odoo.com>2018-05-29 20:00:31 +0200
commita2f275dfc48281648ce4f17b3444f52a25f2595b (patch)
tree9627f227571cda9e8f3dadb2473058b6abd386f9 /addons/web/static/src/js/views/basic/basic_model.js
parentc88da086b5c2e0618de0d5619bfc900307a964c8 (diff)
parent4ea3838d89537c52125a42f5b6f0404b2a070206 (diff)
[MERGE] forward port branch 11.0 up to 4ea3838d895
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.js18
1 files changed, 18 insertions, 0 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 e4d2248d7c3..e3fb780bc52 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -875,6 +875,15 @@ var BasicModel = AbstractModel.extend({
// 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) {
+ if (change.id === elementID &&
+ change.operation === 'ADD' && // For now, only an ADD command increases limits
+ parent.tempLimitIncrement) {
+ // The record will be deleted from the _changes.
+ // So we won't be passing into the logic of _applyX2ManyOperations anymore
+ // implying that we have to cancel out the effects of an ADD command here
+ parent.tempLimitIncrement--;
+ parent.limit--;
+ }
return change.id !== elementID;
});
} else {
@@ -3121,6 +3130,15 @@ var BasicModel = AbstractModel.extend({
// when sent to the server, the x2manys values must be a list
// of commands in a context, but the list of ids in a domain
ids.toJSON = _generateX2ManyCommands.bind(null, fieldName);
+ } else if (field.type === 'one2many') { // Ids are evaluated as a list of ids
+ /* Filtering out virtual ids from the ids list
+ * The server will crash if there are virtual ids in there
+ * The webClient doesn't do literal id list comparison like ids == list
+ * Only relevant in o2m: m2m does create actual records in db
+ */
+ ids = _.filter(ids, function (id) {
+ return typeof id !== 'string';
+ });
}
context[fieldName] = ids;
}