[MIG] mail_activity_reminder: Migration to 16.0

pull/1228/head
Sébastien Alix 2023-10-09 17:52:50 +02:00
parent dbd0e3f9ca
commit 93c326dde3
4 changed files with 7 additions and 11 deletions

View File

@ -4,7 +4,7 @@
{
"name": "Mail Activity Reminder",
"version": "13.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Discuss",
"website": "https://github.com/OCA/social",
"author": "CorporateHub, Odoo Community Association (OCA)",

View File

@ -22,7 +22,6 @@ class MailActivity(models.Model):
string="Last reminder (local)",
)
deadline = fields.Datetime(
string="Deadline",
compute="_compute_deadline",
compute_sudo=True,
store=True,
@ -99,22 +98,20 @@ class MailActivity(models.Model):
)
def action_notify(self):
super().action_notify()
res = super().action_notify()
utc_now = fields.Datetime.now().replace(tzinfo=UTC)
for activity in self:
if activity.last_reminder_local:
continue
tz = timezone(activity.user_id.sudo().tz or "UTC")
activity.last_reminder_local = utc_now.astimezone(tz).replace(tzinfo=None)
return res
def action_remind(self):
"""
Group reminders by user and type and send them together
"""
MailThread = self.env["mail.thread"]
message_activity_assigned = self.env.ref(
"mail_activity_reminder.message_activity_assigned"
)
utc_now = fields.Datetime.now().replace(tzinfo=UTC)
for user in self.mapped("user_id"):
activities = self.filtered(lambda activity: activity.user_id == user)
@ -123,9 +120,9 @@ class MailActivity(models.Model):
subject = _("Some activities you are assigned too expire soon.")
body = message_activity_assigned.render(
body = self.env["ir.qweb"]._render(
"mail_activity_reminder.message_activity_assigned",
dict(activities=activities, model_description="Activities"),
engine="ir.qweb",
minimal_qcontext=True,
)
MailThread.message_notify(

View File

@ -10,7 +10,6 @@ class MailActivityType(models.Model):
_inherit = "mail.activity.type"
reminders = fields.Char(
string="Reminders",
help=(
"A non-digit-separated list of offsets (in days) when reminders"
' should be fired: e.g. 0 means "on the deadline day" while'

View File

@ -9,7 +9,7 @@ from freezegun import freeze_time
from odoo.tests import common
class TestMailActivityReminder(common.SavepointCase):
class TestMailActivityReminder(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@ -114,7 +114,7 @@ class TestMailActivityReminder(common.SavepointCase):
self.assertEqual(activities, activity)
activities.action_remind()
activity.active = False
activity.unlink()
with freeze_time(self.now + relativedelta(days=5)):
activities = self.MailActivity._get_activities_to_remind()
self.assertFalse(activities)