From d8119146c5b8c4b992b8f1c3f48423d5bd02d6c0 Mon Sep 17 00:00:00 2001
From: jordan <jordan@le-filament.com>
Date: Wed, 13 Apr 2022 11:04:15 +0200
Subject: [PATCH] [fix] add condition to avoid unknown element

---
 static/src/js/mail_message.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/static/src/js/mail_message.js b/static/src/js/mail_message.js
index 7b020bb..5906ebc 100755
--- a/static/src/js/mail_message.js
+++ b/static/src/js/mail_message.js
@@ -23,6 +23,11 @@ odoo.define('cgscop_mail_message.MailMessage',function(require){
             var commands = this.options.commandsEnabled ?
                             this._mentionManager.getListenerSelection('/') :
                             [];
+            if (this.$('#oe_restricted_message').length) {
+                var is_restricted = this.$('#oe_restricted_message')[0].checked
+            } else {
+                var is_restricted = false
+            }
             return $.when({
                 content: this._mentionManager.generateLinks(value),
                 attachment_ids: _.pluck(this.get('attachment_ids'), 'id'),
@@ -30,7 +35,7 @@ odoo.define('cgscop_mail_message.MailMessage',function(require){
                 canned_response_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelections()[':'], 'id')),
                 channel_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelection('#'), 'id')),
                 command: commands.length > 0 ? commands[0].name : undefined,
-                restricted: this.$('#oe_restricted_message')[0].checked,
+                restricted: is_restricted
             });
         },
 
-- 
GitLab