diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-03-31 14:10:46 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 3d959382fd92aca6c48ea2413c646edcc1f178f4 (patch) | |
| tree | cd66edd59c9629b08bf314afd9156dbfb8d1bfa8 /addons/web/static/src/js/services/data_manager.js | |
| parent | 2d449f8f1ac314452285e0952a9228b1460a0910 (diff) | |
[FIX] web,mail: one2many records: multiple views
A record of the basic model may need to be displayed in different
views (e.g. a o2m record is displayed in the, e.g., Kanban view
inside the main form view, and if clicked, it is also displayed
in the form view opened in a dialog). However, the fields present
in those views may differ.
The previous implementation of fieldsInfo in the record didn't
handle that, as it was a dict whose keys were field names. With
this commit, the fieldsInfo is dict whose keys are view types, and
the values are dicts whose keys are field names (the fields of
the corresponding views, with they attrs in the view).
This allows to create multiple o2m records in a row in a form view.
Diffstat (limited to 'addons/web/static/src/js/services/data_manager.js')
| -rw-r--r-- | addons/web/static/src/js/services/data_manager.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/addons/web/static/src/js/services/data_manager.js b/addons/web/static/src/js/services/data_manager.js index fa3a2efb231..1a4cebdc955 100644 --- a/addons/web/static/src/js/services/data_manager.js +++ b/addons/web/static/src/js/services/data_manager.js @@ -280,6 +280,7 @@ return core.Class.extend({ // as _ doesn't behave correctly when there is a length key in the object attrs.views = {}; _.each(field.views, function (innerFieldsView, viewType) { + viewType = viewType === 'tree' ? 'list' : viewType; innerFieldsView.type = viewType; attrs.views[viewType] = self._processFieldsView(_.extend({}, innerFieldsView)); }); @@ -317,10 +318,12 @@ return core.Class.extend({ display_name: {type: 'char'}, //id: {type: 'integer'}, }; - attrs.fieldsInfo = {display_name: {}, id: {}}; + attrs.fieldsInfo = {}; + attrs.fieldsInfo.default = {display_name: {}, id: {}}; + attrs.viewType = 'default'; if (attrs.color || 'color') { - attrs.relatedFields[attrs.color || 'color'] = {type: 'int'}; - attrs.fieldsInfo.color = {}; + attrs.relatedFields[attrs.color || 'color'] = {type: 'integer'}; + attrs.fieldsInfo.default.color = {}; } } } @@ -359,12 +362,14 @@ return core.Class.extend({ * @returns {Object} viewInfo */ _processFieldsView: function (viewInfo) { - viewInfo.fieldsInfo = this._processFields(viewInfo.type, viewInfo.arch, viewInfo.fields); - // by default display fetch display_name and id + var viewFields = this._processFields(viewInfo.type, viewInfo.arch, viewInfo.fields); + // by default fetch display_name and id if (!viewInfo.fields.display_name) { viewInfo.fields.display_name = {type: 'char'}; - viewInfo.fieldsInfo.display_name = {}; + viewFields.display_name = {}; } + viewInfo.fieldsInfo = {}; + viewInfo.fieldsInfo[viewInfo.type] = viewFields; utils.deepFreeze(viewInfo.fields); return viewInfo; }, |
