[13.0] [FWD] mail_autosubscribe: Adapt the module to v13.

pull/762/head
nicolas 2021-08-18 15:28:56 -03:00
parent 23ddfb886a
commit b7532891a7
6 changed files with 30 additions and 34 deletions

View File

@ -5,7 +5,7 @@
{
"name": "Mail Autosubscribe",
"summary": "Automatically subscribe partners to its company's business documents",
"version": "14.0.1.0.0",
"version": "13.0.1.0.0",
"author": "Camptocamp SA, Odoo Community Association (OCA)",
"license": "AGPL-3",
"category": "Marketing",

View File

@ -18,22 +18,12 @@ class MailAutosubscribe(models.Model):
]
model_id = fields.Many2one(
"ir.model",
required=True,
index=True,
ondelete="cascade",
"ir.model", required=True, index=True, ondelete="cascade",
)
model = fields.Char(
related="model_id.model",
string="Model Name",
store=True,
index=True,
)
name = fields.Char(
compute="_compute_name",
store=True,
readonly=False,
related="model_id.model", string="Model Name", store=True, index=True,
)
name = fields.Char(compute="_compute_name", store=True, readonly=False,)
@api.depends("model_id")
def _compute_name(self):

View File

@ -2,7 +2,7 @@
# @author Iván Todorovich <ivan.todorovich@gmail.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
from odoo import api, models
class MailThread(models.AbstractModel):
@ -21,7 +21,22 @@ class MailThread(models.AbstractModel):
]
partner_ids += follower_ids
return super().message_subscribe(
partner_ids=partner_ids,
channel_ids=channel_ids,
subtype_ids=subtype_ids,
partner_ids=partner_ids, channel_ids=channel_ids, subtype_ids=subtype_ids,
)
@api.model
def _message_get_default_recipients_on_records(self, records):
# Overload to include auto follow document partners in the composer
# Note: This only works if the template is configured with 'Default recipients'
res = super()._message_get_default_recipients_on_records(records)
if records.env.context.get("no_autosubscribe_followers"):
return res
for rec in records:
partner_ids = res[rec.id]["partner_ids"]
partners = self.env["res.partner"].sudo().browse(partner_ids)
followers = rec._message_get_autosubscribe_followers(partners)
follower_ids = [
follower.id for follower in followers if follower not in partners
]
partner_ids += follower_ids
return res

View File

@ -19,19 +19,3 @@ class BaseModel(models.AbstractModel):
def _message_get_autosubscribe_followers(self, partners):
domain = self._message_get_autosubscribe_followers_domain(partners)
return self.env["res.partner"].sudo().search(domain)
def _message_get_default_recipients(self):
# Overload to include auto follow document partners in the composer
# Note: This only works if the template is configured with 'Default recipients'
res = super()._message_get_default_recipients()
if self.env.context.get("no_autosubscribe_followers"):
return res
for rec in self:
partner_ids = res[rec.id]["partner_ids"]
partners = self.env["res.partner"].sudo().browse(partner_ids)
followers = rec._message_get_autosubscribe_followers(partners)
follower_ids = [
follower.id for follower in followers if follower not in partners
]
partner_ids += follower_ids
return res

View File

@ -0,0 +1 @@
../../../../mail_autosubscribe

View File

@ -0,0 +1,6 @@
import setuptools
setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)