summaryrefslogtreecommitdiff
path: root/addons/website_livechat/models
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-09-24 09:28:20 +0000
committerDavid Beguin <dbe@odoo.com>2019-09-24 13:25:50 +0000
commit33f5bbc7d0808ac61ddd2432aded7cbf66a34e50 (patch)
tree7d815addca754832e4e0e400c558a91a918df497 /addons/website_livechat/models
parent013128699d546b9bc158e93241cf1304d9c05b73 (diff)
[FIX] website_livechat, im_livechat : use visitor display name instead of name
As since 5b9a81a2c6948ecfbd8f8ed3cad1b068fc4231d1 website.visitor.name can be null if the visitor is not linked to a lead or a res.partner, we cannot use the name anymore to build the name of the mail.channel, etc.. Using display_name will always return the correct value, and will include the numbering of the visitor, in order to identify easily the chat windows (if operator is speaking with multi visitor at the same time) Task ID: 2076190 PR #37340
Diffstat (limited to 'addons/website_livechat/models')
-rw-r--r--addons/website_livechat/models/im_livechat_channel.py2
-rw-r--r--addons/website_livechat/models/mail_channel.py4
-rw-r--r--addons/website_livechat/models/website_visitor.py2
3 files changed, 4 insertions, 4 deletions
diff --git a/addons/website_livechat/models/im_livechat_channel.py b/addons/website_livechat/models/im_livechat_channel.py
index dd083c6e104..fb1648a9808 100644
--- a/addons/website_livechat/models/im_livechat_channel.py
+++ b/addons/website_livechat/models/im_livechat_channel.py
@@ -16,7 +16,7 @@ class ImLivechatChannel(models.Model):
'livechat_active': True
})
if not user_id:
- mail_channel_vals['anonymous_name'] = visitor_sudo.name + (' (%s)' % visitor_sudo.country_id.name if visitor_sudo.country_id else '')
+ mail_channel_vals['anonymous_name'] = visitor_sudo.display_name + (' (%s)' % visitor_sudo.country_id.name if visitor_sudo.country_id else '')
# As chat requested by the visitor, delete the chat requested by an operator if any to avoid conflicts between two flows
chat_request_channel = self.env['mail.channel'].sudo().search([('livechat_visitor_id', '=', visitor_sudo.id), ('livechat_active', '=', True)])
for mail_channel in chat_request_channel:
diff --git a/addons/website_livechat/models/mail_channel.py b/addons/website_livechat/models/mail_channel.py
index 48d6d08a847..2eb94f89f8d 100644
--- a/addons/website_livechat/models/mail_channel.py
+++ b/addons/website_livechat/models/mail_channel.py
@@ -34,7 +34,7 @@ class MailChannel(models.Model):
visitor = channel.livechat_visitor_id
if visitor:
channel_infos_dict[channel.id]['visitor'] = {
- 'name': visitor.name,
+ 'name': visitor.display_name,
'country_code': visitor.country_id.code.lower() if visitor.country_id else False,
'is_connected': visitor.is_connected,
'history': self._get_visitor_history(visitor),
@@ -67,7 +67,7 @@ class MailChannel(models.Model):
if not self.channel_message_ids:
return
# Notify that the visitor has left the conversation
- name = _('The visitor') if not self.livechat_visitor_id else self.livechat_visitor_id.name
+ name = _('The visitor') if not self.livechat_visitor_id else self.livechat_visitor_id.display_name
if type == 'cancel':
message = _('has started a conversation with %s. The chat request has been canceled.') % kwargs.get('speaking_with', 'an operator')
else:
diff --git a/addons/website_livechat/models/website_visitor.py b/addons/website_livechat/models/website_visitor.py
index e4020760f8f..84d52f54d47 100644
--- a/addons/website_livechat/models/website_visitor.py
+++ b/addons/website_livechat/models/website_visitor.py
@@ -54,7 +54,7 @@ class WebsiteVisitor(models.Model):
for visitor in self:
operator = self.env.user
country = visitor.country_id
- visitor_name = "%s (%s)" % (visitor.name, country.name) if country else visitor.name
+ visitor_name = "%s (%s)" % (visitor.display_name, country.name) if country else visitor.display_name
mail_channel_vals_list.append({
'channel_partner_ids': [(4, operator.partner_id.id)],
'livechat_channel_id': visitor.website_id.channel_id.id,