summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2018-06-19 14:00:27 +0200
committerNicolas Lempereur <nle@odoo.com>2018-06-22 10:19:51 +0200
commit06d89a8440866fe6cb7b97ea79a65e9faff61843 (patch)
treee4700695240d3afb2b8a416733d586cd1063c66f /addons/web/static/src/js/views/basic
parentadeb570b5a19e362d8357eb03453a40eb9124f4e (diff)
[FIX] web: onchange on not loaded inline list view
Let's assume a one2many A inside a form view, such that the one2many views (list, not editable, and form) are defined inline, and there is an onchange on A. There is another inline one2many B editable list displayed in the inner form view (and B isn't in the list). There are two records on the one2many A, both of them having one record in their one2many B. Edit the first record of A, and edit it's subrecord in B. Click on save. This triggers an onchange on A and the onchange returns a command 5 (DELETE_ALL), and two commands 1 (UPDATE). Now edit the second record of A, and simply close the dialog (e.g. 'Discard'). Save the main record: the record in one2many B of the second record of A has been duplicated. This occured because the code in BasicModel messed up information coming from the onchange (UPDATE command) and from the read (performed when opening the second record), thus producing a CREATE command instead of an UPDATE one. This rev. ensures to properly mix the read data with the onchange result, by transfering the changes over the list datapoint created after the read. opw-1836785 closes #25330
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js5
1 files changed, 5 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 99bf22cc6bd..82bb9e586a8 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -2578,6 +2578,11 @@ 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 () {