mirror of https://github.com/OCA/social.git
[IMP] mail_activity_reminder: Group sendings per user and activity type
parent
7e43dd0a16
commit
60f170a168
|
@ -43,12 +43,6 @@ To configure reminders for specific Activity Type:
|
||||||
when reminders should be fired: e.g. 0 means "on the deadline day" while
|
when reminders should be fired: e.g. 0 means "on the deadline day" while
|
||||||
5 means "5 calendar days before the deadline".
|
5 means "5 calendar days before the deadline".
|
||||||
|
|
||||||
Known issues / Roadmap
|
|
||||||
======================
|
|
||||||
|
|
||||||
* Maybe, group reminders by receiver and send multiple scheduled remiders
|
|
||||||
in one message.
|
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
||||||
|
|
|
@ -11,5 +11,9 @@
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"summary": "Reminder notifications about planned activities",
|
"summary": "Reminder notifications about planned activities",
|
||||||
"depends": ["mail"],
|
"depends": ["mail"],
|
||||||
"data": ["data/mail_activity_reminder_cron.xml", "views/mail_activity_type.xml"],
|
"data": [
|
||||||
|
"data/mail_activity_reminder_cron.xml",
|
||||||
|
"views/mail_activity_type.xml",
|
||||||
|
"data/mail_activity_template.xml",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!--
|
||||||
|
Copyright ACSONE SA/NV
|
||||||
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
<odoo noupdate="1">
|
||||||
|
|
||||||
|
<template id="message_activity_assigned">
|
||||||
|
<div style="margin: 0px; padding: 0px; font-size: 13px;">
|
||||||
|
<span>You have some activities assigned that expire soon:</span>
|
||||||
|
|
||||||
|
<t t-foreach="activities.mapped('activity_type_id')" t-as="activity_type">
|
||||||
|
<h3><span t-field="activity_type.display_name">:</span></h3>
|
||||||
|
<t
|
||||||
|
t-foreach="activities.filtered(lambda activity: activity.activity_type_id == activity_type)"
|
||||||
|
t-as="activity"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
t-field="activity.create_uid.name"
|
||||||
|
/> assigned you an activity <span
|
||||||
|
t-field="activity.activity_type_id.name"
|
||||||
|
/>
|
||||||
|
<t t-if="activity.summary">(<span
|
||||||
|
t-field="activity.summary"
|
||||||
|
/>)</t>
|
||||||
|
on <span t-field="activity.res_name" />
|
||||||
|
to close for <span t-field="activity.date_deadline" />.<br />
|
||||||
|
<p style="margin: 16px 0px 16px 0px;">
|
||||||
|
<a
|
||||||
|
t-att-href="'/mail/view?model=%s&res_id=%s' % (activity.res_model, activity.res_id)"
|
||||||
|
style="background-color:#875A7B; padding: 8px 16px 8px 16px; text-decoration: none; color: #fff; border-radius: 5px;"
|
||||||
|
>
|
||||||
|
View
|
||||||
|
<t t-esc="model_description or 'document'" />
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</odoo>
|
|
@ -98,30 +98,31 @@ class MailActivity(models.Model):
|
||||||
activity.last_reminder_local = utc_now.astimezone(tz).replace(tzinfo=None)
|
activity.last_reminder_local = utc_now.astimezone(tz).replace(tzinfo=None)
|
||||||
|
|
||||||
def action_remind(self):
|
def action_remind(self):
|
||||||
IrModel = self.env["ir.model"]
|
"""
|
||||||
|
Group reminders by user and type and send them together
|
||||||
|
"""
|
||||||
MailThread = self.env["mail.thread"]
|
MailThread = self.env["mail.thread"]
|
||||||
message_activity_assigned = self.env.ref("mail.message_activity_assigned")
|
message_activity_assigned = self.env.ref(
|
||||||
utc_now = fields.Datetime.now().replace(tzinfo=UTC)
|
"mail_activity_reminder.message_activity_assigned"
|
||||||
for activity in self:
|
|
||||||
tz = timezone(activity.user_id.sudo().tz or "UTC")
|
|
||||||
local_now = utc_now.astimezone(tz)
|
|
||||||
model_description = IrModel._get(activity.res_model).display_name
|
|
||||||
subject = _("%s: %s assigned to you, %d day(s) remaining") % (
|
|
||||||
activity.res_name,
|
|
||||||
activity.summary or activity.activity_type_id.name,
|
|
||||||
(activity.date_deadline - local_now.date()).days,
|
|
||||||
)
|
)
|
||||||
|
utc_now = fields.Datetime.now().replace(tzinfo=UTC)
|
||||||
|
for user in self.mapped("user_id"):
|
||||||
|
activities = self.filtered(lambda activity: activity.user_id == user)
|
||||||
|
tz = timezone(user.sudo().tz or "UTC")
|
||||||
|
local_now = utc_now.astimezone(tz)
|
||||||
|
|
||||||
|
subject = _("Some activities you are assigned too expire soon.")
|
||||||
|
|
||||||
body = message_activity_assigned.render(
|
body = message_activity_assigned.render(
|
||||||
dict(activity=activity, model_description=model_description),
|
dict(activities=activities, model_description="Activities"),
|
||||||
engine="ir.qweb",
|
engine="ir.qweb",
|
||||||
minimal_qcontext=True,
|
minimal_qcontext=True,
|
||||||
)
|
)
|
||||||
MailThread.message_notify(
|
MailThread.message_notify(
|
||||||
partner_ids=activity.user_id.partner_id.ids,
|
partner_ids=user.partner_id.ids,
|
||||||
body=body,
|
body=body,
|
||||||
subject=subject,
|
subject=subject,
|
||||||
record_name=activity.res_name,
|
model_description="Activity",
|
||||||
model_description=model_description,
|
|
||||||
notif_layout="mail.mail_notification_light",
|
notif_layout="mail.mail_notification_light",
|
||||||
)
|
)
|
||||||
activity.last_reminder_local = local_now.replace(tzinfo=None)
|
activities.update({"last_reminder_local": local_now.replace(tzinfo=None)})
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
* Maybe, group reminders by receiver and send multiple scheduled remiders
|
|
||||||
in one message.
|
|
|
@ -373,12 +373,11 @@ ul.auto-toc {
|
||||||
<div class="contents local topic" id="contents">
|
<div class="contents local topic" id="contents">
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
|
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
|
||||||
<li><a class="reference internal" href="#known-issues-roadmap" id="id2">Known issues / Roadmap</a></li>
|
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
|
||||||
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
|
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
|
||||||
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
|
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
|
||||||
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
|
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
|
||||||
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
|
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
|
||||||
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -394,17 +393,8 @@ when reminders should be fired: e.g. 0 means “on the deadline day” while
|
||||||
5 means “5 calendar days before the deadline”.</li>
|
5 means “5 calendar days before the deadline”.</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="known-issues-roadmap">
|
|
||||||
<h1><a class="toc-backref" href="#id2">Known issues / Roadmap</a></h1>
|
|
||||||
<blockquote>
|
|
||||||
<ul class="simple">
|
|
||||||
<li>Maybe, group reminders by receiver and send multiple scheduled remiders
|
|
||||||
in one message.</li>
|
|
||||||
</ul>
|
|
||||||
</blockquote>
|
|
||||||
</div>
|
|
||||||
<div class="section" id="bug-tracker">
|
<div class="section" id="bug-tracker">
|
||||||
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
|
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
|
||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
|
@ -412,15 +402,15 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
|
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
|
||||||
<div class="section" id="authors">
|
<div class="section" id="authors">
|
||||||
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
|
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li>CorporateHub</li>
|
<li>CorporateHub</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="contributors">
|
<div class="section" id="contributors">
|
||||||
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
|
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
||||||
<ul class="simple">
|
<ul class="simple">
|
||||||
<li><a class="reference external" href="https://corporatehub.eu/">CorporateHub</a><ul>
|
<li><a class="reference external" href="https://corporatehub.eu/">CorporateHub</a><ul>
|
||||||
<li>Alexey Pelykh <<a class="reference external" href="mailto:alexey.pelykh@corphub.eu">alexey.pelykh@corphub.eu</a>></li>
|
<li>Alexey Pelykh <<a class="reference external" href="mailto:alexey.pelykh@corphub.eu">alexey.pelykh@corphub.eu</a>></li>
|
||||||
|
@ -430,7 +420,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
|
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
|
||||||
<p>This module is maintained by the OCA.</p>
|
<p>This module is maintained by the OCA.</p>
|
||||||
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
|
|
Loading…
Reference in New Issue