summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-03-21 11:04:48 +0100
committerChristophe Simonis <chs@odoo.com>2018-03-21 11:04:48 +0100
commitb51f2d38c247dce9afc04c29774a77d773e3f393 (patch)
tree1133e0dd4c082543d1f361fb7ec160ac0b2cccc6 /addons/web/static/src/js/views/basic/basic_model.js
parentc7dff653d56910fd46e4dcf745c2c6088ce9fc58 (diff)
parent500e3f497057c5d00ae5cc34da7012c6f31f81d4 (diff)
[MERGE] forward port branch saas-11.2 up to 500e3f49705
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.js19
1 files changed, 18 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 3013cb32f85..4cf6f9fa27b 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -370,6 +370,11 @@ var BasicModel = AbstractModel.extend({
elem._changes = null;
elem._isDirty = false;
}
+ elem.offset = 0;
+ if (elem.tempLimitIncrement) {
+ elem.limit -= elem.tempLimitIncrement;
+ delete elem.tempLimitIncrement;
+ }
});
},
/**
@@ -820,6 +825,7 @@ var BasicModel = AbstractModel.extend({
this.discardChanges(id, {rollback: false});
}
} else if (element._changes) {
+ delete element.tempLimitIncrement;
_.each(element._changes, function (change) {
delete change.isNew;
});
@@ -1657,6 +1663,12 @@ var BasicModel = AbstractModel.extend({
// handle multiple add: command[2] may be a dict of values (1
// record added) or an array of dict of values
var data = _.isArray(command.ids) ? command.ids : [command.ids];
+
+ // Ensure the local data repository (list) boundaries can handle incoming records (data)
+ if (data.length + list.res_ids.length > list.limit) {
+ list.limit = data.length + list.res_ids.length;
+ }
+
var list_records = {};
_.each(data, function (d) {
rec = self._makeDataPoint({
@@ -1701,6 +1713,10 @@ var BasicModel = AbstractModel.extend({
case 'CREATE':
var options = {position: command.position};
def = this._addX2ManyDefaultRecord(list, options).then(function (id) {
+ if (command.position === 'bottom' && list.orderedResIDs.length >= list.limit) {
+ list.tempLimitIncrement = (list.tempLimitIncrement || 0) + 1;
+ list.limit += 1;
+ }
// FIXME: hack for lunch widget, which does useless default_get and onchange
if (command.data) {
return self._applyChange(id, command.data);
@@ -3856,7 +3872,8 @@ var BasicModel = AbstractModel.extend({
// generate the current count and res_ids list by applying the changes
var currentCount = list.count;
var currentResIDs = list.res_ids;
- var upperBound = list.limit ? Math.min(list.offset + list.limit, currentCount) : currentCount;
+ var effectiveLimit = (list.limit || 0) - (list.tempLimitIncrement || 0);
+ var upperBound = effectiveLimit ? Math.min(list.offset + effectiveLimit, currentCount) : currentCount;
var fieldNames = list.getFieldNames();
for (var i = list.offset; i < upperBound; i++) {
var resId = currentResIDs[i];