summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-01-22 17:47:32 +0100
committerChristophe Simonis <chs@odoo.com>2018-01-22 17:47:32 +0100
commitfa1f2132e79f2ac2314a8b417d5d35d6571bd41b (patch)
tree3789a8335dd5089998de3c5c6a391b2d95a85187 /addons/web/static/src/js/views/basic
parentdb27489fe756b24647e993a22340705625839698 (diff)
parent950d9b2369046f2e3199d144df8edbd0e63f8a2f (diff)
[MERGE] forward port branch 11.0 up to 950d9b23690
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js23
1 files changed, 9 insertions, 14 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 a6979776c99..5296c6db7d5 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1854,7 +1854,7 @@ var BasicModel = AbstractModel.extend({
model: record.model,
method: 'read',
args: [[record.res_id], fieldNames],
- context: record.getContext(),
+ context: _.extend({}, record.getContext(), {bin_size: true}),
})
.then(function (result) {
if (result.length === 0) {
@@ -2374,7 +2374,7 @@ var BasicModel = AbstractModel.extend({
});
record.data[fieldName] = list.id;
if (!fieldInfo.__no_fetch) {
- var def = self._readUngroupedList(list).then(function (list) {
+ var def = self._readUngroupedList(list).then(function () {
return $.when(
self._fetchX2ManysBatched(list),
self._fetchReferencesBatched(list)
@@ -2403,6 +2403,7 @@ var BasicModel = AbstractModel.extend({
var fields = view ? view.fields : fieldInfo.relatedFields;
var viewType = view ? view.type : fieldInfo.viewType;
list = this._applyX2ManyOperations(list);
+ this._sortList(list);
var x2mRecords = [];
// step 1: collect ids
@@ -2640,7 +2641,7 @@ var BasicModel = AbstractModel.extend({
var relRecordAdded = [];
var relRecordUpdated = [];
_.each(list._changes, function (change) {
- if (change.operation === 'ADD') {
+ if (change.operation === 'ADD' && change.id) {
relRecordAdded.push(self.localData[change.id]);
} else if (change.operation === 'UPDATE' && !self.isNew(change.id)) {
// ignore new records that would have been updated
@@ -2699,6 +2700,10 @@ var BasicModel = AbstractModel.extend({
} else if (_.contains(addedIds, list.res_ids[i])) {
// this is a new id (maybe existing in DB, but new in JS)
relRecord = _.findWhere(relRecordAdded, {res_id: list.res_ids[i]});
+ if (!relRecord) {
+ commands[fieldName].push(x2ManyCommands.link_to(list.res_ids[i]));
+ continue;
+ }
changes = this._generateChanges(relRecord, options);
if (changes.id) {
// the subrecord already exists in db
@@ -3092,23 +3097,13 @@ var BasicModel = AbstractModel.extend({
id: {type: 'integer'},
}, params.fields);
- // datapoint context is extended by fields widgets
- var context = _.extend({}, params.context);
- if (params.fieldsInfo && params.viewType) {
- _.each(params.fieldsInfo[params.viewType], function (field) {
- if (field.context) {
- _.extend(context, field.context);
- }
- });
- }
-
var dataPoint = {
_cache: type === 'list' ? {} : undefined,
_changes: null,
_domains: {},
_rawChanges: {},
aggregateValues: params.aggregateValues || {},
- context: context,
+ context: params.context,
count: params.count || res_ids.length,
data: data,
domain: params.domain || [],