[FIX]mail: detach non existing element

This commit fixes a js crash that occured when the user was trying to
edit a new record while the chatter was not completely loaded
(this.field.thread.$el was not in the dom yet)

Behavior before this fix:
Traceback js & impossible to edit the form afterward.

Behavior after this fix:
no traceback, still possible to edit the form normally.
The thread will display on next chatter re-render. Could be forced by
triggering an onchange.

opw-1986061

closes odoo/odoo#33381

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Moens Alexandre
2019-05-22 06:47:37 +00:00
parent 90dec44a28
commit 40a650a089
+2 -2
View File
@@ -139,7 +139,7 @@ var Chatter = Widget.extend({
if (this.fields.activity) {
this.fields.activity.$el.detach();
}
if (this.fields.thread) {
if (this.fields.thread && this.fields.thread.$el ) {
this.fields.thread.$el.detach();
}
@@ -398,7 +398,7 @@ var Chatter = Widget.extend({
self.fields.followers.$el.insertBefore(self.$('.o_chatter_button_attachment'));
}
}
if (self.fields.thread) {
if (self.fields.thread && self.fields.thread.$el) {
self.fields.thread.$el.appendTo(self.$el);
}
}).always(function () {