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/fields/abstract_field.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/fields/abstract_field.js')
| -rw-r--r-- | addons/web/static/src/js/fields/abstract_field.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js index 01de5fb334c..47802d5d8c7 100644 --- a/addons/web/static/src/js/fields/abstract_field.js +++ b/addons/web/static/src/js/fields/abstract_field.js @@ -92,9 +92,14 @@ var AbstractField = Widget.extend({ // such as the type, the comodel (relation), ... this.field = record.fields[name]; + // the 'viewType' is the type of the view in which the field widget is + // instantiated. For standalone widgets, a 'default' viewType is set. + this.viewType = options.viewType || 'default'; + // the 'attrs' property contains the attributes of the xml 'field' tag, // the inner views... - this.attrs = record.fieldsInfo && record.fieldsInfo[name] || {}; + var fieldsInfo = record.fieldsInfo[this.viewType]; + this.attrs = fieldsInfo && fieldsInfo[name] || {}; // modifiers this.modifiers = JSON.parse(this.attrs.modifiers || "{}"); |
