[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
This commit is contained in:
@@ -2480,7 +2480,7 @@ class MailThread(models.AbstractModel):
|
||||
(
|
||||
'user',
|
||||
lambda pdata: pdata['type'] == 'user',
|
||||
{}
|
||||
{'has_button_access': True}
|
||||
), (
|
||||
'portal',
|
||||
lambda pdata: pdata['type'] == 'portal',
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user