RATIONALE
Channel model is a mail.thread enabled model behaving strangely with followers,
notifications and discuss. Its code should however be simplified to be more
self contained and avoid unwanted side effects on other models.
SPECIFICATIONS
Purpose of this commit is to better differentiate channel members technical
model from partner members in code :
* ``channel_partner_ids``: contacts member of a channel, filtering notably
on active and checking ACLs on res.partner business model. This one
should be used whenever we deal with members of a channel at business
level;
* ``channel_last_seen_partner_ids``: memberships of a channel and technical
model. This one should be used for internal processes and members
management;
Also containing
* clean naming or API of methods managing channel members. This should
not change anything functionally as only code renaming / cleaning is
performed;
* improve performances of channel member auto subscription by aggregating
all members to add and creating them at once;
* check the use of ``mail.channel.partner`` and ``res.partner`` records
through ``channel_last_seen_partner_ids`` and ``channel_partner_ids``
Channel fields;
Functionally nothing should change with this commit. It only cleans code
in order to prepare future modifications.
LINKS
Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
20 lines
777 B
Python
20 lines
777 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, 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, 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
|