diff options
| author | fwi-odoo <fwi@odoo.com> | 2017-04-14 13:02:21 +0200 |
|---|---|---|
| committer | fwi-odoo <fwi@odoo.com> | 2017-04-20 16:41:59 +0200 |
| commit | 86af036ea1175f4a9a5fbca806ab49665fdbc4b0 (patch) | |
| tree | f9d69f2c5c5c766a9a457df59738fea4194a6250 /addons/web/static/src/js/views/basic/basic_view.js | |
| parent | 6da35f7140246d19755da913b4c84fdc16759474 (diff) | |
[FIX] web: fix various bugs when fetching x2manys in form views
- When an one2many is displayed in a list view, the field data are not fully loaded
since only the number of record is displayed. Then when the related form view
is opened the one2many fields displayed need to be loaded.
- Optimized the fetch of x2manys without doing an useless rpc
if we don't need all the fields but only the relation records ids and adapt
the tests for this optimisation.
- Fix wrong inheritance for kanbanmany2many_tags
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_view.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_view.js | 23 |
1 files changed, 23 insertions, 0 deletions
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 2604dcf0aa1..17dc4b97125 100644 --- a/addons/web/static/src/js/views/basic/basic_view.js +++ b/addons/web/static/src/js/views/basic/basic_view.js @@ -66,6 +66,29 @@ var BasicView = AbstractView.extend({ var viewType = this.viewType; var viewFields = Object.keys(record.fieldsInfo[viewType]); var fieldNames = _.difference(viewFields, Object.keys(record.data)); + // Suppose that in a form view, there is an x2many list view with + // an x2many field F of the related record, and that F is also + // displayed in the x2many form view (e.g. as a list or a kanban). + // In this case, F is represented in record.data + // (as it is known by the x2many list view), but its related fields + // (those displayed in the list or kanban) still need to be fetched. + // So when this happens, F is added to the list of fieldNames to fetch. + _.each(viewFields, function (name) { + if (!_.contains(fieldNames, name)) { + var fieldType = record.fields[name].type; + if ((fieldType === 'one2many' || fieldType === 'many2many')) { + if (!('fieldsInfo' in record.data[name])) { + fieldNames.push(name); + } else { + var recordViewTypes = Object.keys(record.data[name].fieldsInfo); + var fieldViewTypes = Object.keys(record.fieldsInfo[viewType][name].views); + if (_.difference(fieldViewTypes, recordViewTypes).length) { + fieldNames.push(name); + } + } + } + } + }); if (fieldNames.length && !this.model.isNew(record.id)) { return this.model.reload(this.recordID, { fieldNames: fieldNames, |
