Repository navigation
[18.0][MIG] crm_reminder_email_activities: Migration to 18.0 #756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
Changes from all commits
5700fd0
bf0cf2e
7ab06c9
bff303c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| 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", | ||
| ], | ||
| } |
| 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> |
| 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> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import crm_lead |
| 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): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Please consider moving these methods to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
| 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): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Please consider using
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [build-system] | ||
| requires = ["whool"] | ||
| build-backend = "whool.buildapi" |
| 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>\> |
| 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. |
| 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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