Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions crm_reminder_email_activities/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
=============================
CRM Reminder email activities
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f3971269550a898135a10a05b02486c5ab0e969791ce164fc0eb37f9cbdfa6a8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcrm-lightgray.png?logo=github
:target: https://github.com/OCA/crm/tree/18.0/crm_reminder_email_activities
:alt: OCA/crm
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/crm-18-0/crm-18-0-crm_reminder_email_activities
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/crm&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module introduces email reminders that summarize for users the
active activities due in the following 7 days.

**Table of contents**

.. contents::
:local:

Known issues / Roadmap
======================

A possible improvement is the implementation of the ability to customize
the time interval of reminders.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/crm/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/crm/issues/new?body=module:%20crm_reminder_email_activities%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* PyTech SRL

Contributors
------------

- `PyTech SRL <https://pytech.it>`__:

- Alessandro Pecchini <alessandro.pecchini@pytech.it>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/crm <https://github.com/OCA/crm/tree/18.0/crm_reminder_email_activities>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions crm_reminder_email_activities/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
20 changes: 20 additions & 0 deletions crm_reminder_email_activities/__manifest__.py

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Please clarify in the PR description that this is porting an unmerged module: from the point of view of the reviewer this changes the approach.
When reviewing a migration of a merged module the reviewer just has to check that the module is correctly adapted to the target version; if the module was never merged, it has to be reviewed in full like a brand new module.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, PR related information and unmerged related comments are updated

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "CRM Reminder email activities",
"summary": """
This module periodically sends a reminder email for
activities related to leads that expire within 7 days.
""",
"version": "18.0.1.0.0",
"author": "PyTech SRL, Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/crm",
"application": False,
"installable": True,
"depends": [
"crm",
],
"data": [
"data/ir_cron.xml",
"data/mail_template_reminder.xml",
],
}
14 changes: 14 additions & 0 deletions crm_reminder_email_activities/data/ir_cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="crm_email_reminder_activities_cron" model="ir.cron">
<field name="name">Reminder CRM planned activities</field>
<field name="model_id" ref="model_crm_lead" />
<field name="active" eval="True" />
<field name="state">code</field>
<field name="code">model.cron_send_crm_reminder_activities()</field>
<field name="interval_number">1</field>
<field name="interval_type">weeks</field>
<field name="nextcall" eval="(DateTime.today() + relativedelta(weekday=6))" />
<field name="user_id" ref="base.user_root" />
</record>
</odoo>
91 changes: 91 additions & 0 deletions crm_reminder_email_activities/data/mail_template_reminder.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo noupdate="1">
<record id="email_template_crm_reminder_activities" model="mail.template">
<field name="name">Reminder CRM planned activities</field>
<field name="model_id" ref="crm.model_crm_lead" />
<field name="email_from">{{object.env.user.email_formatted}}</field>
<field name="partner_to">{{object.partner_id.id}}</field>
<field name="auto_delete" eval="True" />
<field name="subject">Reminder CRM planned activities</field>
<field name="body_html" type="html">
<div style="max-width: 500px">
<t t-set="activity_owner" t-value="ctx.get('activity_owner', '')" />
<!-- HEADER -->
<span style="font-size: 0.75rem;">Reminder CRM planned activities
</span>
<br />
<span style="font-size: 1.3rem; font-weight: bold; margin-top: 14px;">
<t t-out="activity_owner.name or ''">User</t>
</span>
<hr
width="100%"
style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0;margin: 16px 0px;"
/>

<!-- CONTENT -->
<t
t-set="activities"
t-value="object._get_crm_activities(user=activity_owner)"
/>
<div style="font-size: 0.9rem;">
<p style="margin-bottom: 10px; font-size: 1rem;">Dear <t
t-out="activity_owner.name or ''"
>User</t>,
</p>
<p>Below are your active CRM app tasks due in the next 7 days:
</p>
<ul>
<t t-foreach="activities" t-as="activity">
<li>
<t
t-set="activity_obj"
t-value="object.env[activity.res_model].browse(activity.res_id)"
/>
<p style="margin-bottom: 5px">Deadline:
<span
t-field="activity.date_deadline"
t-options="{'widget': 'date'}"
/>
</p>
<p style="margin-top: 5px">
<span t-out="activity_obj.display_name" />
-
<span
t-out="activity.summary or activity_obj.activity_type_id.display_name"
/>
</p>
</li>
</t>
</ul>
</div>
<hr
width="100%"
style="background-color:rgb(204,204,204);border:medium none;clear:both;display:block;font-size:0px;min-height:1px;line-height:0;margin: 16px 0px;"
/>

<!-- FOOTER -->
<p t-out="object.company_id.name or ''" style="font-size: 0.8rem;" />
<div style="font-size: 0.8rem;opacity: 0.7;">
<t t-out="object.company_id.phone or ''" />
<t t-if="object.company_id.email">
|
<a
t-att-href="'mailto:%s' % object.company_id.email"
style="text-decoration:none; color: #454748;"
t-out="object.company_id.email or ''"
/>

</t>
<t t-if="object.company_id.website">
|
<a
t-att-href="'%s' % object.company_id.website"
style="text-decoration:none; color: #454748;"
t-out="object.company_id.website or ''"
/>
</t>
</div>
</div>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions crm_reminder_email_activities/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import crm_lead
34 changes: 34 additions & 0 deletions crm_reminder_email_activities/models/crm_lead.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from dateutil.relativedelta import relativedelta

from odoo import api, fields, models


class CrmLead(models.Model):
_inherit = "crm.lead"

@api.model
def cron_send_crm_reminder_activities(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Please consider moving these methods to crm.lead: if everyone did this, the res.users model would be full of methods for every kind of model.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using crm.lead model as suggested

users = self._get_crm_activities().mapped("user_id")
try:
mail_template = self.env.ref(
"crm_reminder_email_activities.email_template_crm_reminder_activities"
)
for user in users:
mail_template.with_context(activity_owner=user).send_mail(
self.id, email_values={"email_to": user.email}
)
except ValueError as err:
raise ValueError(
self.env._("CRM Reminder Activities Mail Template not found.")
) from err

def _get_crm_activities(self, user=None):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Please consider using self for the user, instead of user since we are in the res.users model.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As 'crm.lead' model is used, changes are taken care accordingly

today = fields.Date.context_today(self)
domain = [
("res_model", "=", "crm.lead"),
("date_deadline", ">=", today),
("date_deadline", "<=", today + relativedelta(days=+7)),
]
if user:
domain.append(("user_id", "=", user.id))
return self.env["mail.activity"].search(domain, order="date_deadline asc")
3 changes: 3 additions & 0 deletions crm_reminder_email_activities/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions crm_reminder_email_activities/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [PyTech SRL](https://pytech.it):
- Alessandro Pecchini \<<alessandro.pecchini@pytech.it>\>
1 change: 1 addition & 0 deletions crm_reminder_email_activities/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module introduces email reminders that summarize for users the active activities due in the following 7 days.
1 change: 1 addition & 0 deletions crm_reminder_email_activities/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A possible improvement is the implementation of the ability to customize the time interval of reminders.
Loading
Loading