From f879cf28677a516b0cc01c671166de68d9c992e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 19 Jan 2022 11:26:43 +0000 Subject: [PATCH] [IMP] sale: give followers links in notification emails In this commit we get the old "Pay Now" behavior back that gives a standard link to followers. It is done manually on sale order as it implements portal rules. Follower group for notification layout is therefore activated. Task-2712450 (Mail/Sale: Improve 'Pay Now' notification template) Part-of: odoo/odoo#82167 --- addons/sale/models/sale_order.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index efb93685af4..758506cdcc8 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -1075,12 +1075,17 @@ class SaleOrder(models.Model): the document so they don't have the access button. """ groups = super(SaleOrder, self)._notify_get_recipients_groups(msg_vals=msg_vals) if self._context.get('proforma'): - for group in [g for g in groups if g[0] in ('portal_customer', 'customer')]: + for group in [g for g in groups if g[0] in ('portal_customer', 'portal', 'follower', 'customer')]: group[2]['has_button_access'] = False return groups + local_msg_vals = dict(msg_vals or {}) - customer_portal_group = next(group for group in groups if group[0] == 'portal_customer') - if customer_portal_group: + # portal customers have full access (existence not granted, depending on partner_id) + try: + customer_portal_group = next(group for group in groups if group[0] == 'portal_customer') + except StopIteration: + pass + else: access_opt = customer_portal_group[2].setdefault('button_access', {}) is_tx_pending = self.get_portal_last_transaction().state == 'pending' if self.has_to_be_signed(include_draft=True): @@ -1093,6 +1098,17 @@ class SaleOrder(models.Model): elif self.state in ('draft', 'sent'): access_opt['title'] = _('View Quotation') + # enable followers that have access through portal + follower_group = next(group for group in groups if group[0] == 'follower') + follower_group[2]['active'] = True + follower_group[2]['has_button_access'] = True + access_opt = follower_group[2].setdefault('button_access', {}) + if self.state in ('draft', 'sent'): + access_opt['title'] = _('View Quotation') + else: + access_opt['title'] = _('View Order') + access_opt['url'] = self._notify_get_action_link('view', **local_msg_vals) + return groups def preview_sale_order(self):