[MIG] mail_optional_autofollow: Migration to 15.0

This commit is contained in:
Karl Southern 2022-04-01 13:09:06 +01:00 committed by Benoit Aimont
parent eb52dc9a3b
commit 2a930968ae
3 changed files with 8 additions and 8 deletions

View File

@ -8,7 +8,7 @@
"author": "ACSONE SA/NV," "Odoo Community Association (OCA)", "author": "ACSONE SA/NV," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/social", "website": "https://github.com/OCA/social",
"category": "Social Network", "category": "Social Network",
"version": "13.0.1.0.0", "version": "15.0.1.0.0",
"license": "AGPL-3", "license": "AGPL-3",
"depends": ["mail"], "depends": ["mail"],
"data": ["wizard/mail_compose_message_view.xml"], "data": ["wizard/mail_compose_message_view.xml"],

View File

@ -21,13 +21,13 @@ class TestAttachExistingAttachment(common.TransactionCase):
} }
) )
mail_compose = self.env["mail.compose.message"] mail_compose = self.env["mail.compose.message"]
values = mail_compose.with_context(ctx).onchange_template_id( values = mail_compose.with_context(**ctx)._onchange_template_id(
False, "comment", "res.partner", self.partner_01.id False, "comment", "res.partner", self.partner_01.id
)["value"] )["value"]
values["partner_ids"] = [(4, self.partner_02.id)] values["partner_ids"] = [(4, self.partner_02.id)]
compose_id = mail_compose.with_context(ctx).create(values) compose_id = mail_compose.with_context(**ctx).create(values)
compose_id.autofollow_recipients = False compose_id.autofollow_recipients = False
compose_id.with_context(ctx).send_mail() compose_id.with_context(**ctx).action_send_mail()
res = self.env["mail.followers"].search( res = self.env["mail.followers"].search(
[ [
("res_model", "=", "res.partner"), ("res_model", "=", "res.partner"),
@ -37,9 +37,9 @@ class TestAttachExistingAttachment(common.TransactionCase):
) )
# I check if the recipient isn't a follower # I check if the recipient isn't a follower
self.assertEqual(len(res.ids), 0) self.assertEqual(len(res.ids), 0)
compose_id = mail_compose.with_context(ctx).create(values) compose_id = mail_compose.with_context(**ctx).create(values)
compose_id.autofollow_recipients = True compose_id.autofollow_recipients = True
compose_id.with_context(ctx).send_mail() compose_id.with_context(**ctx).action_send_mail()
res = self.env["mail.followers"].search( res = self.env["mail.followers"].search(
[ [
("res_model", "=", "res.partner"), ("res_model", "=", "res.partner"),

View File

@ -21,10 +21,10 @@ class MailComposeMessage(models.TransientModel):
followers on the related object""", followers on the related object""",
) )
def send_mail(self, auto_commit=False): def _action_send_mail(self, auto_commit=False):
for wizard in self: for wizard in self:
super( super(
MailComposeMessage, MailComposeMessage,
wizard.with_context(mail_post_autofollow=wizard.autofollow_recipients), wizard.with_context(mail_post_autofollow=wizard.autofollow_recipients),
).send_mail(auto_commit=auto_commit) )._action_send_mail(auto_commit=auto_commit)
return True return True