| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
from odoo import models |
| 5 |
|
| 6 |
|
| 7 |
class DiscussChannel(models.Model): |
| 8 |
_inherit = 'discuss.channel' |
| 9 |
|
| 10 |
def _convert_visitor_to_lead(self, partner, key): |
| 11 |
""" When website is installed, we can link the created lead from /lead command |
| 12 |
to the current website_visitor. We do not use the lead name as it does not correspond |
| 13 |
to the lead contact name.""" |
| 14 |
lead = super()._convert_visitor_to_lead(partner, key) |
| 15 |
visitor_sudo = self.livechat_visitor_id.sudo() |
| 16 |
if visitor_sudo: |
| 17 |
visitor_sudo.write({'lead_ids': [(4, lead.id)]}) |
| 18 |
lead.country_id = lead.country_id or visitor_sudo.country_id |
| 19 |
return lead |