diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2018-11-13 16:21:18 +0000 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2018-11-19 12:57:52 +0000 |
| commit | cac91731221b5ac122ad745ac408b406d335e5c7 (patch) | |
| tree | 3064849ef8d38ef13580f12fe2bba8d65e0a0810 /addons/web/static/src/js/views/basic/basic_model.js | |
| parent | 108b43c60a1a14f27b62562f069bcb09818d2394 (diff) | |
[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
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.js | 10 |
1 files changed, 5 insertions, 5 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 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 () { |
