Skip to content

[18.0][MIG] crm_reminder_email_activities: Migration to 18.0 - #756

Open
anusriNPS wants to merge 4 commits into
OCA:18.0from
PyTech-SRL:18.0-mig-crm_reminder_email_activities
Open

anusriNPS wants to merge 4 commits into
OCA:18.0from
PyTech-SRL:18.0-mig-crm_reminder_email_activities

Conversation

@anusriNPS

@anusriNPS anusriNPS commented Jul 21, 2026 •

Copy link
Copy Markdown

Migrating below PR which contains unmerged module crm_reminder_email_activities from 16.0 to 18.0

Related 16.0 PR: #753

@OCA-git-bot OCA-git-bot added series:18.0 mod:crm_reminder_email_activities Module crm_reminder_email_activities labels Jul 21, 2026
@anusriNPS
anusriNPS force-pushed the 18.0-mig-crm_reminder_email_activities branch from e497f5e to 0704efa Compare July 21, 2026 11:16
@anusriNPS anusriNPS changed the title [18.0][MIIG] crm_reminder_email_activities: Migration to 18.0 [18.0][MIG] crm_reminder_email_activities: Migration to 18.0 Jul 21, 2026
@anusriNPS

Copy link
Copy Markdown
Author
image

@HekkiMelody HekkiMelody left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code and functional review, LGTM

Module was originally proposed for v16 here: #753

@SirPyTech SirPyTech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the PR!
This is good, I suggested some improvements but nothing worth blocking from merge in my opinion.

<field name="interval_type">weeks</field>
<field
name="nextcall"
eval="(DateTime.today() + relativedelta(weekday=6)).strftime('%Y-%m-%d')"

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: strftime might not be needed.

Moreover, why postponing the first call?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The idea is to send the reminder on a Sunday, containing the activities for the coming week.

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.

nextcall field being a datetime type removed using strftime as datetime object is accepted by field

_inherit = "res.users"

@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

@api.model
def cron_send_crm_reminder_activities(self):
users = self._get_crm_activities().mapped("user_id")
mail_template = self.env.ref(

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 handle the case where the template does not exist, this might be a good opportunity to add a test for this piece of code.

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.

Updated handling of case without template and added testcase as suggested

for user in users:
mail_template.send_mail(user.id)

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

from odoo.tests.common import TransactionCase, new_test_user


class TestEmailReminderPlannedActivity(TransactionCase):

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: We could use BaseCommon to reduce the mail logs as suggested in https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-18.0:

evaluate the use of BaseCommon as base test class if you need to setup company, currency, users and groups in a special way)

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.

Inherited from Basecommon and included tracking_disable to env context

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

t-value="object.env[activity.res_model].browse(activity.res_id)"
/>
<p style="margin-bottom: 5px">Deadline:
<span t-out="activity.date_deadline" />

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: Consider formatting this date in the user's locale, it might suffice using t-field instead of t-out.

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 t-field as suggested

@anusriNPS
anusriNPS force-pushed the 18.0-mig-crm_reminder_email_activities branch from 0704efa to 20bfb76 Compare September 29, 2026 06:37
@anusriNPS
anusriNPS marked this pull request as draft September 29, 2026 07:40
   Using "crm.lead" as model instead of "res.users" and
modified module accordingly.Introduced testcase to
verify sending of mail for crm activities when related
mail template is not available.
@anusriNPS
anusriNPS force-pushed the 18.0-mig-crm_reminder_email_activities branch from 20bfb76 to bff303c Compare September 30, 2026 07:01
@anusriNPS
anusriNPS marked this pull request as ready for review September 30, 2026 07:01
@anusriNPS

Copy link
Copy Markdown
Author

Verified with latest update on using crm.lead model:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants