diff --git a/addons/auth_signup/__manifest__.py b/addons/auth_signup/__manifest__.py index bf3c9d64c81..81f6cbdb285 100644 --- a/addons/auth_signup/__manifest__.py +++ b/addons/auth_signup/__manifest__.py @@ -17,6 +17,7 @@ Allow users to sign up and reset their password ], 'data': [ 'data/auth_signup_data.xml', + 'data/ir_cron_data.xml', 'views/res_config_settings_views.xml', 'views/res_users_views.xml', 'views/auth_signup_login_templates.xml', diff --git a/addons/auth_signup/data/auth_signup_data.xml b/addons/auth_signup/data/auth_signup_data.xml index 88852ce662b..5fe062a6d44 100644 --- a/addons/auth_signup/data/auth_signup_data.xml +++ b/addons/auth_signup/data/auth_signup_data.xml @@ -197,6 +197,58 @@ + + + Auth Signup: Unregistered Users + + Reminder for unregistered users + ${object.company_id.partner_id.email_formatted|safe} + ${object.email_formatted|safe} + + +
+ + + + + + + +
+ + % set invited_users = ctx['invited_users'] + + + +
+ + Pending Invitations +

+
+
+ Dear ${object.name or ''},

+ You added the following user(s) to your database but they haven't registered yet: +
    + % for invited_user in invited_users: +
  • ${invited_user}
  • + % endfor +
+ Follow up with them so they can access your database and start working with you. +

+ Have a nice day!
+ --
The ${object.company_id.name} Team +
+
+
+
+
+
+
+ ${object.partner_id.lang} + + +
+ Auth Signup: Odoo Account Created diff --git a/addons/auth_signup/data/ir_cron_data.xml b/addons/auth_signup/data/ir_cron_data.xml new file mode 100644 index 00000000000..b583d5e65fd --- /dev/null +++ b/addons/auth_signup/data/ir_cron_data.xml @@ -0,0 +1,13 @@ + + + + Users: Notify About Unregistered Users + + code + model.send_unregistered_user_reminder() + + 1 + days + -1 + + diff --git a/addons/auth_signup/models/res_users.py b/addons/auth_signup/models/res_users.py index f7c35761987..559f92f9fb5 100644 --- a/addons/auth_signup/models/res_users.py +++ b/addons/auth_signup/models/res_users.py @@ -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 @@ class ResUsers(models.Model): template.with_context(lang=user.lang).send_mail(user.id, force_send=True, raise_exception=True) _logger.info("Password reset email sent for user <%s> to <%s>", user.login, user.email) + @api.multi + def send_unregistered_user_reminder(self, after_days=5): + datetime_min = fields.Datetime.today() - 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), + ('create_uid.email', '!=', 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.mail_template_data_unregistered_users').with_context(dbname=self._cr.dbname, invited_users=invited_users[user]) + template.send_mail(user, notif_layout='mail.mail_notification_light', force_send=False) + @api.model def web_dashboard_create_users(self, emails): inactive_users = self.search([('state', '=', 'new'), '|', ('login', 'in', emails), ('email', 'in', emails)])