summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_model.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-10-25 15:17:38 +0200
committerAaron Bohy <aab@odoo.com>2017-10-26 08:22:00 +0200
commit16c90138bde648782bef81c9b499a486ccdcb7c6 (patch)
tree6296b435b837d1498ac62c6980939dd156856191 /addons/web/static/src/js/views/basic/basic_model.js
parent2a1456a29c7be2365115d58b3555e69ab5604c77 (diff)
[FIX] web: handle onchange on nested one2manys
Suppose that we have a form view with a one2many field o2m_1, displayed as a list. The model of o2m_1 contains a one2many field o2m_2 which isn't displayed in the list view, but which is in the form view. If an onchange sets the value of o2m_1, e.g. with a command 0 to create a new record, and that the value of o2m_2 for this new record is set (e.g. with a command 0 as well), it crashed.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_model.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js
index a2731d881d3..9f8ea3227f5 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1313,15 +1313,17 @@ var BasicModel = AbstractModel.extend({
} else {
var fieldInfo = record.fieldsInfo[viewType][name];
if (!fieldInfo) {
- return; //ignore changes of x2many not in view
+ return; // ignore changes of x2many not in view
}
+ var view = fieldInfo.views && fieldInfo.views[fieldInfo.mode];
list = self._makeDataPoint({
- fieldsInfo: fieldInfo.fieldsInfo,
+ fields: view ? view.fields : fieldInfo.relatedFields,
+ fieldsInfo: view ? view.fieldsInfo : fieldInfo.fieldsInfo,
modelName: field.relation,
parentID: record.id,
static: true,
type: 'list',
- viewType: fieldInfo.viewType,
+ viewType: view ? view.type : fieldInfo.viewType,
});
}
// TODO: before registering the changes, verify that the x2many