summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_view.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-03-31 14:10:46 +0200
committerAaron Bohy <aab@odoo.com>2017-04-11 19:44:38 +0200
commit3d959382fd92aca6c48ea2413c646edcc1f178f4 (patch)
treecd66edd59c9629b08bf314afd9156dbfb8d1bfa8 /addons/web/static/src/js/views/basic/basic_view.js
parent2d449f8f1ac314452285e0952a9228b1460a0910 (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/views/basic/basic_view.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_view.js11
1 files changed, 8 insertions, 3 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 5b8a3a7d0c9..46ecb5d7e38 100644
--- a/addons/web/static/src/js/views/basic/basic_view.js
+++ b/addons/web/static/src/js/views/basic/basic_view.js
@@ -40,9 +40,9 @@ var BasicView = AbstractView.extend({
'action_buttons' in params ? params.action_buttons : true;
this.loadParams.fieldsInfo = viewInfo.fieldsInfo;
- this.loadParams.fieldNames = _.keys(viewInfo.fieldsInfo);
this.loadParams.fields = viewInfo.fields;
this.loadParams.limit = parseInt(viewInfo.arch.attrs.limit, 10) || params.limit;
+ this.loadParams.viewType = this.viewType;
this.recordID = params.recordID;
},
@@ -60,9 +60,14 @@ var BasicView = AbstractView.extend({
_loadData: function () {
if (this.recordID) {
var record = this.model.get(this.recordID);
- var fieldNames = _.difference(record.fieldNames, Object.keys(record.data));
+ var viewType = this.viewType;
+ var viewFields = Object.keys(record.fieldsInfo[viewType]);
+ var fieldNames = _.difference(viewFields, Object.keys(record.data));
if (fieldNames.length && !this.model.isNew(record.id)) {
- return this.model.reload(this.recordID, {fieldNames: fieldNames});
+ return this.model.reload(this.recordID, {
+ fieldNames: fieldNames,
+ viewType: viewType,
+ });
} else {
return $.when(this.recordID);
}