From 40a650a089af5311e8bfdd0384859a0bc67a6270 Mon Sep 17 00:00:00 2001 From: Moens Alexandre Date: Wed, 15 May 2019 08:52:10 +0000 Subject: [PATCH] [FIX]mail: detach non existing element MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/mail/static/src/js/chatter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index dc23354fe7b..635d261bf3f 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -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 () {