summaryrefslogtreecommitdiff
path: root/addons/website_crm_livechat
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-10-07 15:05:10 +0000
committerDavid Beguin <dbe@odoo.com>2019-11-20 13:33:08 +0000
commitdc101d12a59583563f0969d1a8eeb4406a107f99 (patch)
tree52a8d4ef25ea45fb76d78137a9e999e7a19aa309 /addons/website_crm_livechat
parent75dc5149555458596501491d81983cdcc774be29 (diff)
[IMP] website_crm_livechat : link visitor to lead on /lead command
If an operator executes the /lead commands, the visitor was not linked to the lead. This commit fixed that. The visitor is now linked to the lead but the visitor does not take the lead's name. (As '/lead leadName' creates a lead with 'leadName' as name but not as contact name and the visitor needs the contact name of the lead) Task ID: 2081534 PR #38706 closes odoo/odoo#41960 X-original-commit: 8c257a6219f72118af4e81c14fb2c6c9f320df17 Signed-off-by: David Beguin <dbeguin@users.noreply.github.com>
Diffstat (limited to 'addons/website_crm_livechat')
-rw-r--r--addons/website_crm_livechat/models/__init__.py1
-rw-r--r--addons/website_crm_livechat/models/mail_channel.py18
2 files changed, 19 insertions, 0 deletions
diff --git a/addons/website_crm_livechat/models/__init__.py b/addons/website_crm_livechat/models/__init__.py
index 00140f99c9f..e81172ec3dd 100644
--- a/addons/website_crm_livechat/models/__init__.py
+++ b/addons/website_crm_livechat/models/__init__.py
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import crm_lead
+from . import mail_channel
diff --git a/addons/website_crm_livechat/models/mail_channel.py b/addons/website_crm_livechat/models/mail_channel.py
new file mode 100644
index 00000000000..8d0c2442cc6
--- /dev/null
+++ b/addons/website_crm_livechat/models/mail_channel.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import models
+
+
+class MailChannel(models.Model):
+ _inherit = 'mail.channel'
+
+ def _convert_visitor_to_lead(self, partner, channel_partners, key):
+ """ When website is installed, we can link the created lead from /lead command
+ to the current website_visitor. We do not use the lead name as it does not correspond
+ to the lead contact name."""
+ lead = super(MailChannel, self)._convert_visitor_to_lead(partner, channel_partners, key)
+ visitor_sudo = self.livechat_visitor_id.sudo()
+ if visitor_sudo:
+ visitor_sudo.write({'lead_ids': [(4, lead.id)]})
+ return lead