[IMP] mail_activity_reminder: pre-commit stuff

pull/1228/head
Sébastien Alix 2023-10-09 17:50:01 +02:00
parent 3be624a1a2
commit dbd0e3f9ca
4 changed files with 25 additions and 6 deletions

View File

@ -18,9 +18,14 @@ class MailActivity(models.Model):
compute_sudo=True,
store=True,
)
last_reminder_local = fields.Datetime(string="Last reminder (local)",)
last_reminder_local = fields.Datetime(
string="Last reminder (local)",
)
deadline = fields.Datetime(
string="Deadline", compute="_compute_deadline", compute_sudo=True, store=True,
string="Deadline",
compute="_compute_deadline",
compute_sudo=True,
store=True,
)
@api.model
@ -42,7 +47,10 @@ class MailActivity(models.Model):
return activities
@api.depends(
"user_id.tz", "activity_type_id.reminders", "deadline", "last_reminder_local",
"user_id.tz",
"activity_type_id.reminders",
"deadline",
"last_reminder_local",
)
def _compute_next_reminder(self):
now = fields.Datetime.now()
@ -68,7 +76,9 @@ class MailActivity(models.Model):
)
)
for reminder in reminders:
next_reminder_local = local_deadline - relativedelta(days=reminder,)
next_reminder_local = local_deadline - relativedelta(
days=reminder,
)
if not last_reminder_local or next_reminder_local > last_reminder_local:
break
if last_reminder_local and next_reminder_local <= last_reminder_local:
@ -99,7 +109,7 @@ class MailActivity(models.Model):
def action_remind(self):
"""
Group reminders by user and type and send them together
Group reminders by user and type and send them together
"""
MailThread = self.env["mail.thread"]
message_activity_assigned = self.env.ref(

View File

@ -16,7 +16,9 @@ class TestMailActivityReminder(common.SavepointCase):
cls.env = cls.env(
context=dict(
cls.env.context, tracking_disable=True, no_reset_password=True,
cls.env.context,
tracking_disable=True,
no_reset_password=True,
)
)
cls.ResUsers = cls.env["res.users"]

View File

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

View File

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