Skip to content
Browse files

[IMP] auth_signup : send a reminder to the user who added another use…

…r in Odoo

Purpose of the task is to sent a mail template to the user who added another user(s) in Odoo.

It informs user about the details of users who have been invited by him
but have still not registered after given days of creation (default->5days)

Closes #31582
  • Loading branch information...
pch-odoo committed Feb 21, 2019
1 parent b01ce6e commit 85324108dbc23296b8c7e4f7804817f7ee8b4ac3
@@ -17,6 +17,7 @@
'data': [
@@ -197,6 +197,58 @@
<field name="user_signature" eval="False"/>

<!-- Email template for reminder of unregistered users -->
<record id="unregistered_user_reminder" model="mail.template">
<field name="name">Auth Signup: Unregistered Users</field>
<field name="model_id" ref="base.model_res_users"/>
<field name="subject">Reminder for unregistered users</field>
<field name="email_from">${object.company_id.partner_id.email_formatted|safe}</field>
<field name="email_to">${object.email_formatted|safe}</field>
<field name="body_html" type="html">
<table border="0" cellpadding="0" cellspacing="0" style="background-color: #F1F1F1; font-family:Verdana, Arial,sans-serif; color: #454748; width: 100%; border-collapse:separate;"><tr><td align="center">
<table border="0" cellpadding="0" cellspacing="0" width="590" style="padding: 16px; background-color: white; color: #454748; border-collapse:separate;">
<!-- CONTENT -->
<td align="center" style="min-width: 590px;">
<table border="0" cellpadding="0" cellspacing="0" width="590" style="min-width: 590px; background-color: white; padding: 0px 8px 0px 8px; border-collapse:separate;">
% set invited_users = ctx['invited_users']
<td style="text-align : center">
<span style="font-size: 20px; font-weight: bold;">
Pending Invitations
<tr><td valign="top" style="font-size: 13px;">
Dear ${ or ''},<br/> <br/>
You added the following user(s) to your database but they haven't registered yet:
% for invited_user in invited_users:
% endfor
Follow up with them so they can access your database and start working with you.
<br /><br/>
Have a nice day!<br />
--<br/>The ${} Team
<tr><td style="text-align:center;">
<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 16px 0px;"/>
<field name="lang">${object.partner_id.lang}</field>
<field name="auto_delete" eval="True"/>
<field name="user_signature" eval="False"/>

<!-- Email template for new users that used a signup token -->
<record id="mail_template_user_signup_account_created" model="mail.template">
<field name="name">Auth Signup: Odoo Account Created</field>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<record id="ir_cron_auth_signup_send_pending_user_reminder" model="ir.cron">
<field name="name">Mail: Notify About Unregistered Users</field>
<field name="model_id" ref="model_res_users"/>
<field name="state">code</field>
<field name="code">model.send_unregistered_user_reminder(after_days=5)</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
@@ -4,6 +4,8 @@
import logging

from ast import literal_eval
from collections import defaultdict
from dateutil.relativedelta import relativedelta

from odoo import api, fields, models, _
from odoo.exceptions import UserError
@@ -201,6 +203,28 @@ def action_reset_password(self):
template.with_context(lang=user.lang).send_mail(, force_send=True, raise_exception=True)"Password reset email sent for user <%s> to <%s>", user.login,

def send_unregistered_user_reminder(self, after_days=5):
datetime_min = - relativedelta(days=after_days)
datetime_max = datetime_min + relativedelta(hours=23, minutes=59, seconds=59)

res_users_with_details = self.env['res.users'].search_read([
('share', '=', False),
('', '!=', False),
('create_date', '>=', datetime_min),
('create_date', '<=', datetime_max),
('log_ids', '=', False)], ['create_uid', 'name', 'login'])

# group by invited by
invited_users = defaultdict(list)
for user in res_users_with_details:
invited_users[user.get('create_uid')[0]].append("%s (%s)" % (user.get('name'), user.get('login')))

# For sending mail to all the invitors about their invited users
for user in invited_users:
template = self.env.ref('auth_signup.unregistered_user_reminder').with_context(dbname=self._cr.dbname, invited_users=invited_users[user])
template.send_mail(user, notif_layout='mail.mail_notification_light', force_send=True)

def web_dashboard_create_users(self, emails):
inactive_users =[('state', '=', 'new'), '|', ('login', 'in', emails), ('email', 'in', emails)])

0 comments on commit 8532410

Please sign in to comment.
You can’t perform that action at this time.