diff options
| author | Aaron Bohy <aab@odoo.com> | 2020-03-03 12:09:46 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-03-09 14:14:39 +0000 |
| commit | f894b6a1d88f8ac946bc3481668e6556f72e83c0 (patch) | |
| tree | aa591d0c607276fcdb809a1a46c9bc0113a626af /addons/web/static/src/js/views/basic/basic_model.js | |
| parent | 8a52f10ceb9e3a70cf729e511a6962bbed952333 (diff) | |
[FIX] web: x2many: use correct viewType
This commit fixes two issues that occurred in the following
situation: in a form view, have a one2many field F1 displayed as a
list, that contains another one2many field F2, displayed with
widget many2many_tags (in the list), and with a list in the form
(in the dialog). In the dialog, the list of F2 displays a
field, say 'name', which has an onchange that sets 'display_name'.
Moreover, there is an onchange in the (main) form view, that
populates F1 and F2, for instance, it returns something like: {
F1: [[5], [0, 0, {
F2: [[5], [0, 0, {
display_name: 'xxx',
name: 'xxx',
}]]
}]]
}
1) If the user opens a related record in F1, and adds (in the
dialog) a related record in F2, then validates the dialog, the
newly created record in F2 isn't correctly displayed in the
many2many_tags (the display_name is `false`), i.e. the onchange
hasn't been applied.
2) If field 'name' in F2 in the list is required, the new record
can't be saved, even if the user enters a correct value.
In both cases, the reason is that we use the incorrect viewType in
datapoints: as we don't specify that we specifically want 'list',
the 'default' one is taken, and we thus use the fieldsInfo of the
many2many_tags, which only knows field 'display_name'. As a
consequence, onchanges aren't correctly applied (issue 1), and
fields aren't correctly reset (issue 2).
Issue reported on task 2189529
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 | 2 |
1 files changed, 1 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 00ff4464eff..e5f20378dea 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1997,7 +1997,7 @@ var BasicModel = AbstractModel.extend({ case 'UPDATE': list._changes.push({operation: 'UPDATE', id: command.id}); if (command.data) { - defs.push(this._applyChange(command.id, command.data)); + defs.push(this._applyChange(command.id, command.data, { viewType: view.type })); } break; case 'FORGET': |
