summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2020-03-03 12:09:46 +0000
committerAaron Bohy <aab@odoo.com>2020-03-09 14:14:39 +0000
commitf894b6a1d88f8ac946bc3481668e6556f72e83c0 (patch)
treeaa591d0c607276fcdb809a1a46c9bc0113a626af /addons/web/static/src/js/fields
parent8a52f10ceb9e3a70cf729e511a6962bbed952333 (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/fields')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 58fc8d99229..8aa894307d1 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -1110,7 +1110,7 @@ var FieldX2Many = AbstractField.extend({
// case, we can re-render the whole subview.
if (command && command.operation === 'UPDATE' && command.data) {
var state = record.data[this.name];
- var fieldNames = state.getFieldNames();
+ var fieldNames = state.getFieldNames({ viewType: 'list' });
this._reset(record, ev);
return this.renderer.confirmUpdate(state, command.id, fieldNames, ev.initialEvent);
}