From 54d091448b3d4d6c1878ef463e47a0f4b18b4e2b Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Thu, 3 Nov 2016 16:15:34 +0100 Subject: [PATCH] [FIX] sale, website_portal_sale: see portal button With a9bd9ab1 the access action was refined depending on the user. But when sending a mail about a sale order, this lead to an issue since a mail template is rendered with the current user and not the mail recipients. So in the case of a sale order, the recipient could not have a button leading to /my/orders/{order_id} whilst he should have, because the user used to render the mail was the sender (which was an employee and not a share user). This commit adds a context key "force_website" which force the action to an available /my/orders even if the sender is not a share user. opw-691040 --- addons/sale/data/mail_template_data.xml | 2 +- addons/website_portal_sale/models/sale_order.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale/data/mail_template_data.xml b/addons/sale/data/mail_template_data.xml index 709d0187277..dfb4ac3f041 100644 --- a/addons/sale/data/mail_template_data.xml +++ b/addons/sale/data/mail_template_data.xml @@ -15,7 +15,7 @@ ${object.partner_id.lang} Dear ${object.partner_id.name} -% set access_action = object.get_access_action() +% set access_action = object.with_context(force_website=True).get_access_action() % set doc_name = 'quotation' if object.state in ('draft', 'sent') else 'order confirmation' % set is_online = access_action and access_action['type'] == 'ir.actions.act_url' % set access_name = is_online and object.template_id and 'Accept and pay %s online' % doc_name or 'View %s' % doc_name diff --git a/addons/website_portal_sale/models/sale_order.py b/addons/website_portal_sale/models/sale_order.py index d36779d8797..6ce53b45284 100644 --- a/addons/website_portal_sale/models/sale_order.py +++ b/addons/website_portal_sale/models/sale_order.py @@ -16,7 +16,7 @@ class SaleOrder(models.Model): self.ensure_one() if self.state == 'cancel' or (self.state == 'draft' and not self.env.context.get('mark_so_as_sent')): return super(SaleOrder, self).get_access_action() - if self.env.user.share: + if self.env.user.share or self.env.context.get('force_website'): try: self.check_access_rule('read') except exceptions.AccessError: