From cac91731221b5ac122ad745ac408b406d335e5c7 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 13 Nov 2018 16:21:18 +0000 Subject: [FIX] web: m2o+o2m in o2m onchange no lose data Steps: - open a modal form view from tree view first line and make a change - open a modal from the second line and make a change - open the second line back: the change were lost In a given number of conditions (a many2one inside the form view, there is a one2many in the form view not inside the tree view, ....) this happened because: - when we save the first line, we get onchange data for the second one - this onchange data can't be applied before second line is loaded, but it is saved so it can be applied if second line is ever opened - when the second line is opened the saved change is applied => OK - when the second line is opened a second time the saved change is applied again, possibly overwriting posterious change => BAD With this changeset, when the record with unapplied onchange is loaded for the first time, the unapplied onchange is applied only once. Added test without the change failed with: - only 1 turtle for second partner (result: 0 not 1) - second partner turtle is Michelangelo (result: "" not "Michelangelo") opw-1846820 closes #28644 --- addons/web/static/src/js/views/basic/basic_model.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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 50f1f13808b..b9832996de5 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1439,6 +1439,11 @@ var BasicModel = AbstractModel.extend({ record._rawChanges[name] = val; return; } + if (record._rawChanges[name]) { + // if previous _rawChanges exists, clear them since the field is now knwon + // and restoring outdated onchange over posterious change is wrong + delete record._rawChanges[name]; + } var oldValue = name in record._changes ? record._changes[name] : record.data[name]; var id; if (field.type === 'many2one') { @@ -2552,11 +2557,6 @@ var BasicModel = AbstractModel.extend({ relationField: field.relation_field, viewType: view ? view.type : fieldInfo.viewType, }); - // set existing changes to the list - if (record._changes && record._changes[fieldName]) { - list._changes = self.localData[record._changes[fieldName]]._changes; - record._changes[fieldName] = list.id; - } record.data[fieldName] = list.id; if (!fieldInfo.__no_fetch) { var def = self._readUngroupedList(list).then(function () { -- cgit v1.2.3 From e713ed2a69af9fe97fbe2d54843adc8f1ce689aa Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 20 Nov 2018 09:00:43 +0000 Subject: [FIX] web: implement filter orderedBy related to: #28446 On a pure list view, click on a column to sort the records by that field. Save the filter as favorite Reload, now apply the filter Before this commit, there were two issues: 1. The order of the list was never propagated to search view, which couldn't save the filter with its attribute "sort" 2. There was no mechanism to load the attribute sort from a loading Filter After this commit, those two issues are corrected Unfortunately, complex search view flows are not testable in v11.0 OPW 1906968 closes odoo/odoo#28766 --- addons/web/static/src/js/views/basic/basic_model.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic/basic_model.js') 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 b9832996de5..0372f7cd5e7 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -3332,7 +3332,7 @@ var BasicModel = AbstractModel.extend({ model: params.modelName, offset: params.offset || (type === 'record' ? _.indexOf(res_ids, res_id) : 0), openGroupByDefault: params.openGroupByDefault, - orderedBy: params.orderedBy || [], + orderedBy: params.orderedBy || (params.context && params.context.orderedBy) || [], orderedResIDs: params.orderedResIDs, parentID: params.parentID, rawContext: params.rawContext, @@ -4016,6 +4016,7 @@ var BasicModel = AbstractModel.extend({ if (options.context !== undefined) { element.context = options.context; + element.orderedBy = options.context.orderedBy || element.orderedBy; } if (options.domain !== undefined) { element.domain = options.domain; -- cgit v1.2.3