Issue ----- Automatic assignation assign leads mostly based on country. So far the country need to be set manually on the lead. Solution -------- Since we have the information on the website vistor works, set the country on the lead from the visitor website. Unless the visitor is link to a partner with a country. In that case setting a country will cancel the address sync from the partner to the lead. closes odoo/odoo#59575 X-original-commit: eff2b357db179e6e62f3db58ca2d90cc61c3748f Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
20 lines
813 B
Python
20 lines
813 B
Python
# -*- 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)]})
|
|
lead.country_id = lead.country_id or visitor_sudo.country_id
|
|
return lead
|