From 6aa3a88190213b9213e97ae66713ebe232cabc05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 7 Jan 2022 12:36:10 +0000 Subject: [PATCH] [FIX] portal, various: give access to portal in customer emails by default Records inheriting from portal mixin implement their own access to portal using tokens. Activating the access button by default seems the right thing to do instead of having to do it manually in each addon. Access is granted at record level using tokens and access URLs anyway. This eases future improvements of "Pay Now" notification template as it will use the ``has_access_button`` instead of doing custom computation directly in the template itself. Task-2712450 (Mail/Sale: Improve 'Pay Now' notification template) Part-of: odoo/odoo#82627 --- addons/mail/models/mail_thread.py | 2 +- addons/portal/models/portal_mixin.py | 2 +- addons/project/models/project.py | 2 +- addons/sale/models/sale_order.py | 14 -------------- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 37dffb764ea..820f9a25cd0 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2480,7 +2480,7 @@ class MailThread(models.AbstractModel): ( 'user', lambda pdata: pdata['type'] == 'user', - {} + {'has_button_access': True} ), ( 'portal', lambda pdata: pdata['type'] == 'portal', diff --git a/addons/portal/models/portal_mixin.py b/addons/portal/models/portal_mixin.py index bbd9576c094..be4f9e762cb 100644 --- a/addons/portal/models/portal_mixin.py +++ b/addons/portal/models/portal_mixin.py @@ -73,7 +73,7 @@ class PortalMixin(models.AbstractModel): new_group = [ ('portal_customer', lambda pdata: pdata['id'] == customer.id, { - 'has_button_access': False, + 'has_button_access': True, 'button_access': { 'url': access_link, }, diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 1d14da9bc35..42bf5d445c2 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -1975,7 +1975,7 @@ class Task(models.Model): {} )) portal_privacy = self.project_id.privacy_visibility == 'portal' - for group_name, group_method, group_data in groups: + for group_name, _group_method, group_data in groups: if group_name in ('customer', 'user') or group_name == 'portal_customer' and not portal_privacy: group_data['has_button_access'] = False elif group_name == 'portal_customer' and portal_privacy: diff --git a/addons/sale/models/sale_order.py b/addons/sale/models/sale_order.py index 168a09deb9f..3fda7ef1349 100644 --- a/addons/sale/models/sale_order.py +++ b/addons/sale/models/sale_order.py @@ -1069,20 +1069,6 @@ class SaleOrder(models.Model): transaction = self.get_portal_last_transaction() return (self.state == 'sent' or (self.state == 'draft' and include_draft)) and not self.is_expired and self.require_payment and transaction.state != 'done' and self.amount_total - def _notify_get_groups(self, msg_vals=None): - """ Give access button to users and portal customer as portal is integrated - in sale. Customer and portal group have probably no right to see - the document so they don't have the access button. """ - groups = super(SaleOrder, self)._notify_get_groups(msg_vals=msg_vals) - - self.ensure_one() - if self.state not in ('draft', 'cancel'): - for group_name, group_method, group_data in groups: - if group_name not in ('customer', 'portal'): - group_data['has_button_access'] = True - - return groups - def preview_sale_order(self): self.ensure_one() return {