diff --git a/addons/mail/data/mail_data.xml b/addons/mail/data/mail_data.xml index ad6f58665c2..c30ba66b37b 100644 --- a/addons/mail/data/mail_data.xml +++ b/addons/mail/data/mail_data.xml @@ -91,18 +91,6 @@ ${ctx['button_access']['title']} % endif - % if ctx.get('has_button_follow'): - % if ctx.get('has_button_access'): - | - % endif - ${ctx['button_follow']['title']} - % elif ctx.get('has_button_unfollow'): - % if ctx.get('has_button_access'): - | - % endif - ${ctx['button_unfollow']['title']} - % endif - % if ctx.get('actions'): % for action in ctx['actions']: | diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index bf43e1c8a4d..4d9ff5f3369 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -652,14 +652,6 @@ class MailThread(models.AbstractModel): * has_button_access: whether to display Access in email. True by default for new groups, False for portal / customer. * button_access: dict with url and title of the button - * has_button_follow: whether to display Follow in email (if recipient is - not currently following the thread). True by default for new groups, - False for portal / customer. - * button_follow: dict with url adn title of the button - * has_button_unfollow: whether to display Unfollow in email (if recipient - is currently following the thread). True by default for new groups, - False for portal / customer. - * button_unfollow: dict with url and title of the button * actions: list of action buttons to display in the notification email. Each action is a dict containing url and title of the button. @@ -672,17 +664,8 @@ class MailThread(models.AbstractModel): def _message_notification_recipients(self, message, recipients): # At this point, all access rights should be ok. We sudo everything to # access rights checks and speedup the computation. - recipients_sudo = recipients.sudo() result = {} - doc_followers = self.env['mail.followers'] - if message.model and message.res_id: - doc_followers = self.env['mail.followers'].sudo().search([ - ('res_model', '=', message.model), - ('res_id', '=', message.res_id), - ('partner_id', 'in', recipients_sudo.ids)]) - partner_followers = doc_followers.mapped('partner_id') - if self._context.get('auto_delete', False): access_link = self._notification_link_helper('view') else: @@ -698,13 +681,9 @@ class MailThread(models.AbstractModel): ('user', lambda partner: bool(partner.user_ids) and not any(user.share for user in partner.user_ids), {}), ('portal', lambda partner: bool(partner.user_ids) and all(user.share for user in partner.user_ids), { 'has_button_access': False, - 'has_button_follow': False, - 'has_button_unfollow': False, }), ('customer', lambda partner: True, { 'has_button_access': False, - 'has_button_follow': False, - 'has_button_unfollow': False, }) ] @@ -715,25 +694,13 @@ class MailThread(models.AbstractModel): group_data.setdefault('button_access', { 'url': access_link, 'title': view_title}) - group_data.setdefault('has_button_follow', True) - group_data.setdefault('button_follow', { - 'url': self._notification_link_helper('follow', model=message.model, res_id=message.res_id), - 'title': _('Follow')}) - group_data.setdefault('has_button_unfollow', True) - group_data.setdefault('button_unfollow', { - 'url': self._notification_link_helper('unfollow', model=message.model, res_id=message.res_id), - 'title': _('Unfollow')}) group_data.setdefault('actions', list()) - group_data.setdefault('followers', self.env['res.partner']) - group_data.setdefault('not_followers', self.env['res.partner']) + group_data.setdefault('recipients', self.env['res.partner']) for recipient in recipients: for group_name, group_func, group_data in groups: if group_func(recipient): - if recipient in partner_followers: - group_data['followers'] |= recipient - else: - group_data['not_followers'] |= recipient + group_data['recipients'] |= recipient break for group_name, group_method, group_data in groups: diff --git a/addons/mail/models/res_partner.py b/addons/mail/models/res_partner.py index 6114adcce7b..77d61185ed0 100644 --- a/addons/mail/models/res_partner.py +++ b/addons/mail/models/res_partner.py @@ -179,29 +179,14 @@ class Partner(models.Model): emails = self.env['mail.mail'] recipients_nbr, recipients_max = 0, 50 for email_type, recipient_template_values in recipients.items(): - if recipient_template_values['followers']: + if recipient_template_values['recipients']: # generate notification email content - template_fol_values = dict(base_template_ctx, **recipient_template_values) # fixme: set button_unfollow to none - template_fol_values['has_button_follow'] = False - template_fol = base_template.with_context(**template_fol_values) + template_ctx = dict(base_template_ctx, **recipient_template_values) # fixme: set button_unfollow to none + template = base_template.with_context(**template_ctx) # generate templates for followers and not followers - fol_values = template_fol.generate_email(message.id, fields=['body_html', 'subject']) + fol_values = template.generate_email(message.id, fields=['body_html', 'subject']) # send email - new_emails, new_recipients_nbr = self._notify_send(fol_values['body'], fol_values['subject'], recipient_template_values['followers'], **base_mail_values) - # update notifications - self._notify_udpate_notifications(new_emails) - - emails |= new_emails - recipients_nbr += new_recipients_nbr - if recipient_template_values['not_followers']: - # generate notification email content - template_not_values = dict(base_template_ctx, **recipient_template_values) # fixme: set button_follow to none - template_not_values['has_button_unfollow'] = False - template_not = base_template.with_context(**template_not_values) - # generate templates for followers and not followers - not_values = template_not.generate_email(message.id, fields=['body_html', 'subject']) - # send email - new_emails, new_recipients_nbr = self._notify_send(not_values['body'], not_values['subject'], recipient_template_values['not_followers'], **base_mail_values) + new_emails, new_recipients_nbr = self._notify_send(fol_values['body'], fol_values['subject'], recipient_template_values['recipients'], **base_mail_values) # update notifications self._notify_udpate_notifications(new_emails)