diff --git a/addons/im_livechat/__manifest__.py b/addons/im_livechat/__manifest__.py
index fd5fda2126b..4d988093a94 100644
--- a/addons/im_livechat/__manifest__.py
+++ b/addons/im_livechat/__manifest__.py
@@ -20,6 +20,7 @@ Help your customers with this chat, and analyse their feedback.
""",
'data': [
"data/mail_shortcode_data.xml",
+ "data/mail_data.xml",
"data/im_livechat_channel_data.xml",
"security/im_livechat_channel_security.xml",
"security/ir.model.access.csv",
diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py
index 8e56c2279f3..b90a418f8cd 100644
--- a/addons/im_livechat/controllers/main.py
+++ b/addons/im_livechat/controllers/main.py
@@ -148,3 +148,9 @@ class LivechatController(http.Controller):
Channel = request.env['mail.channel']
channel = Channel.sudo().search([('uuid', '=', uuid)], limit=1)
channel.notify_typing(is_typing=is_typing, is_website_user=True)
+
+ @http.route('/im_livechat/email_livechat_transcript', type='json', auth='public', cors="*")
+ def email_livechat_transcript(self, uuid, email):
+ channel = request.env['mail.channel'].sudo().search([('uuid', '=', uuid)], limit=1)
+ if channel:
+ channel._email_livechat_transcript(email)
diff --git a/addons/im_livechat/data/mail_data.xml b/addons/im_livechat/data/mail_data.xml
new file mode 100644
index 00000000000..13fe131fb3a
--- /dev/null
+++ b/addons/im_livechat/data/mail_data.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Livechat Conversation
+
+
+
+ |
+
+ |
+
+
+ |
+
+ |
+
+
+
+
+
+
+
+ |
+
+ Hello, Here's a copy of your conversation with
+ , on the
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+ |
+
+
+ |
+
+ |
+
+
+
+
+ Best regards,
+
+
+ |
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+|
+ Powered by Odoo
+ |
+
+
+
+
diff --git a/addons/im_livechat/models/mail_channel.py b/addons/im_livechat/models/mail_channel.py
index 7939379ea8c..433c7ff4c53 100644
--- a/addons/im_livechat/models/mail_channel.py
+++ b/addons/im_livechat/models/mail_channel.py
@@ -159,3 +159,20 @@ class MailChannel(models.Model):
def _rating_get_parent_field_name(self):
return 'livechat_channel_id'
+
+ def _email_livechat_transcript(self, email):
+ company = self.env.user.company_id
+ render_context = {
+ "company": company,
+ "channel": self,
+ }
+ template = self.env.ref('im_livechat.livechat_email_template')
+ mail_body = template.render(render_context, engine='ir.qweb', minimal_qcontext=True)
+ mail_body = self.env['mail.thread']._replace_local_links(mail_body)
+ mail = self.env['mail.mail'].create({
+ 'subject': _('Conversation with %s') % self.livechat_operator_id.name,
+ 'email_from': self.env.company.email,
+ 'email_to': email,
+ 'body_html': mail_body,
+ })
+ mail.send()
diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js
index 086f02daa32..44c7dad0f05 100644
--- a/addons/im_livechat/static/src/js/im_livechat.js
+++ b/addons/im_livechat/static/src/js/im_livechat.js
@@ -410,6 +410,8 @@ var Feedback = Widget.extend({
'click .o_livechat_rating_choices img': '_onClickSmiley',
'click .o_livechat_no_feedback span': '_onClickNoFeedback',
'click .o_rating_submit_button': '_onClickSend',
+ 'click .o_email_chat_button': '_onEmailChat',
+ 'click .o_livechat_email_error .alert-link': '_onTryAgain',
},
/**
@@ -451,6 +453,15 @@ var Feedback = Widget.extend({
}
});
},
+ /**
+ * @private
+ */
+ _showThanksMessage: function () {
+ this.$('.o_livechat_rating_box').empty().append($('
', {
+ text: _t('Thank you for your feedback'),
+ class: 'text-muted'
+ }));
+ },
//--------------------------------------------------------------------------
// Handlers
@@ -466,6 +477,7 @@ var Feedback = Widget.extend({
* @private
*/
_onClickSend: function () {
+ this._showThanksMessage();
if (_.isNumber(this.rating)) {
this._sendFeedback({ reason: this.$('textarea').val(), close: true });
}
@@ -480,14 +492,48 @@ var Feedback = Widget.extend({
this.$('.o_livechat_rating_choices img[data-value="'+this.rating+'"]').addClass('selected');
// only display textearea if bad smiley selected
- var shouldCloseChatWindow = false;
if (this.rating !== 10) {
this.$('.o_livechat_rating_reason').show();
} else {
this.$('.o_livechat_rating_reason').hide();
- shouldCloseChatWindow = true;
+ this._showThanksMessage();
}
- this._sendFeedback({ close: shouldCloseChatWindow });
+ this._sendFeedback({ close: false });
+ },
+ /**
+ * @private
+ */
+ _onEmailChat: function () {
+ var self = this;
+ var $email = this.$('#o_email');
+
+ if (utils.is_email($email.val())) {
+ $email.removeAttr('title').removeClass('is-invalid').prop('disabled', true);
+ this.$('.o_email_chat_button').prop('disabled', true);
+ this._rpc({
+ route: '/im_livechat/email_livechat_transcript',
+ params: {
+ uuid: this._livechat.getUUID(),
+ email: $email.val(),
+ }
+ }).then(function () {
+ self.$('.o_livechat_email').html($('', { text: _t('Conversation Sent') }));
+ }).guardedCatch(function () {
+ self.$('.o_livechat_email').hide();
+ self.$('.o_livechat_email_error').show();
+ });
+ } else {
+ $email.addClass('is-invalid').prop('title', _t('Invalid email address'));
+ }
+ },
+ /**
+ * @private
+ */
+ _onTryAgain: function () {
+ this.$('#o_email').prop('disabled', false);
+ this.$('.o_email_chat_button').prop('disabled', false);
+ this.$('.o_livechat_email_error').hide();
+ this.$('.o_livechat_email').show();
},
});
diff --git a/addons/im_livechat/static/src/scss/im_livechat.scss b/addons/im_livechat/static/src/scss/im_livechat.scss
index 409b6a6726c..9b1142cbefd 100644
--- a/addons/im_livechat/static/src/scss/im_livechat.scss
+++ b/addons/im_livechat/static/src/scss/im_livechat.scss
@@ -32,17 +32,25 @@
padding: 15px;
font-size: 14px;
+ .o_livechat_email {
+ font-size: 12px;
+ > div {
+ padding: 5px 0;
+ }
+ }
+
.o_livechat_no_feedback {
text-decoration: underline;
cursor: pointer;
+ margin: 20px 0;
}
- .o_livechat_rating_feedback_text {
- margin-top: 65px;
+ .o_livechat_rating_box {
+ margin: 40px 0 30px 0;
}
.o_livechat_rating_choices {
- margin: 40px 0;
+ margin: 10px 0;
> img {
width: 65px;
diff --git a/addons/im_livechat/static/src/xml/im_livechat.xml b/addons/im_livechat/static/src/xml/im_livechat.xml
index c96f9a05393..c437e87eab0 100644
--- a/addons/im_livechat/static/src/xml/im_livechat.xml
+++ b/addons/im_livechat/static/src/xml/im_livechat.xml
@@ -4,16 +4,15 @@
-
- Did we correctly answer your question ?
-
-
-
-
I don't want to rate this conversation
+
+
+ Did we correctly answer your question ?
+
+
@@ -21,6 +20,22 @@
+
+
Receive a copy of this conversation
+
+
+
+
+
+
+ Oops! Something went wrong.
Please check your internet connection.
+
Try again
+
+
+ Close conversation
+