summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2018-10-16 11:54:10 +0000
committerAaron Bohy <aab@odoo.com>2018-10-17 08:44:49 +0000
commitbd004ac75e2249fded10e69c7e1d3bf5b5f64911 (patch)
tree09640319482cf361d89f5004ba905e05bb85e559 /addons/mail/static/src
parenta1e052a4b46fb60c6673f49bc5e83dae3d045637 (diff)
[FIX] mail: chatter in x2many form view
Since rev. 755a8d815a, it crashed when the user tried to open an x2many record in form view (thus in a dialog), if there was a chatter in that form's arch. This was because the wrong viewType was used (for instance, list or kanban instead of form), to look into fieldsInfo, and thus the chatter fields couldn't be found. opw 1891378 opw 1892520 opw 1893100 closes odoo/odoo#27844
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/js/chatter.js5
-rw-r--r--addons/mail/static/src/js/form_renderer.js1
2 files changed, 5 insertions, 1 deletions
diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js
index 780cd58deec..2f2e1a0e770 100644
--- a/addons/mail/static/src/js/chatter.js
+++ b/addons/mail/static/src/js/chatter.js
@@ -44,6 +44,9 @@ var Chatter = Widget.extend({
* @param {string} [mailFields.mail_activity]
* @param {string} [mailFields.mail_followers]
* @param {string} [mailFields.mail_thread]
+ * @param {Object} options
+ * @param {string} [options.viewType=record.viewType] current viewType in
+ * which the chatter is instantiated
*/
init: function (parent, record, mailFields, options) {
this._super.apply(this, arguments);
@@ -66,7 +69,7 @@ var Chatter = Widget.extend({
}
if (mailFields.mail_thread) {
this.fields.thread = new ThreadField(this, mailFields.mail_thread, record, options);
- var fieldsInfo = this.record.fieldsInfo[record.viewType];
+ var fieldsInfo = record.fieldsInfo[options.viewType || record.viewType];
var nodeOptions = fieldsInfo[mailFields.mail_thread].options || {};
this.hasLogButton = options.display_log_button || nodeOptions.display_log_button;
this.postRefresh = nodeOptions.post_refresh || 'never';
diff --git a/addons/mail/static/src/js/form_renderer.js b/addons/mail/static/src/js/form_renderer.js
index 21477f825c9..91d2c2033c4 100644
--- a/addons/mail/static/src/js/form_renderer.js
+++ b/addons/mail/static/src/js/form_renderer.js
@@ -54,6 +54,7 @@ FormRenderer.include({
if (!this.chatter) {
this.chatter = new Chatter(this, this.state, this.mailFields, {
isEditable: this.activeActions.edit,
+ viewType: 'form',
});
this.chatter.appendTo($('<div>'));
this._handleAttributes(this.chatter.$el, node);