From e7b40e783a9cdbacb919d2328da18746cfb4fd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 7 Jan 2022 12:14:56 +0000 Subject: [PATCH] [FIX] sale: clean unnecessary portal/access code Override of ``get_access_action`` in sale_management is useless. Indeed it redirects to the portal when * there is an order template; * user is share OR force_website is in context; This override calls ``get_portal_url``. This method basically crafts link like ``access_url?access_token=TOKEN`` as no other argument is given to portal url computation method. Using the standard ``get_access_action`` gives the same result. When having read rights on the record (which is implied for current code), portal override already calls ``_get_share_url``. Moreover portal version effectively checks requested access_uid has read access while current override uses current user which may lead to strange results depending on call chain. Removing this kind of override simplifies management of notification emails and buttons, especially that "Pay Now" template is about to be cleaned. This notably partially reverts odoo/odoo@b49da62365e442f780c50fa6290edf07cf375ac4 and some other commits. Those are anyway linked to mails sent when sale did not have its portal available directly from sale as portal was a side module. Website quote was adding its own portal-related logic (accept and pay). All this is now standard in sale and it makes sense to use standard ``get_access_action`` code when possible. Task-2712450 (Mail/Sale: Improve 'Pay Now' notification template) Part-of: odoo/odoo#82627 --- addons/sale_management/models/sale_order.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/addons/sale_management/models/sale_order.py b/addons/sale_management/models/sale_order.py index c6d95bea3a3..2b430efba7e 100644 --- a/addons/sale_management/models/sale_order.py +++ b/addons/sale_management/models/sale_order.py @@ -135,20 +135,6 @@ class SaleOrder(models.Model): order.sale_order_template_id.mail_template_id.send_mail(order.id) return res - def get_access_action(self, access_uid=None): - """ Instead of the classic form view, redirect to the online quote if it exists. """ - self.ensure_one() - user = access_uid and self.env['res.users'].sudo().browse(access_uid) or self.env.user - - if not self.sale_order_template_id or (not user.share and not self.env.context.get('force_website')): - return super().get_access_action(access_uid) - return { - 'type': 'ir.actions.act_url', - 'url': self.get_portal_url(), - 'target': 'self', - 'res_id': self.id, - } - def update_prices(self): super().update_prices() # Special case: we want to overwrite the existing discount on update_prices call