From 6bb4b6698d08c687f5f113cacef31bee3dfd42db Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Wed, 12 Dec 2018 10:18:57 +0000 Subject: [FIX] web: x2m in x2m with different fields in different views Use case: a x2m (ex: attribute values) displayed in a x2m (ex: attributes on product) using different fields in different views (ex: tags in product form view and list in product attribute form view). When opening the x2m record (in a wizard) then going back on the form view, the tags are empty because the `display_name` value has been lost when fetching x2m for the second time. In this case, the list `fieldsInfo` needs to be updated with the existing (default for tags) one so all the fields will be correctly loaded. Task 1916891 closes odoo/odoo#29598 --- addons/web/static/src/js/views/basic/basic_view.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'addons/web/static/src/js/views/basic/basic_view.js') diff --git a/addons/web/static/src/js/views/basic/basic_view.js b/addons/web/static/src/js/views/basic/basic_view.js index cdb1cc05290..d966129b547 100644 --- a/addons/web/static/src/js/views/basic/basic_view.js +++ b/addons/web/static/src/js/views/basic/basic_view.js @@ -107,6 +107,21 @@ var BasicView = AbstractView.extend({ if (_.difference(fieldViewTypes, recordViewTypes).length) { fieldNames.push(name); } + + if (record.data[name].viewType === 'default') { + // Use case: x2many (tags) in x2many list views + // When opening the x2many record form view, the + // x2many will be reloaded but it may not have + // the same fields (ex: tags in list and list in + // form) so we need to merge the fieldsInfo to + // avoid losing the initial fields (display_name) + var defaultFieldInfo = record.data[name].fieldsInfo.default; + _.each(fieldViews, function (fieldView) { + _.each(fieldView.fieldsInfo, function (x2mFieldInfo) { + _.defaults(x2mFieldInfo, defaultFieldInfo); + }); + }); + } } } // Many2one: context is not the same between the different views -- cgit v1.2.3