From b49da62365e442f780c50fa6290edf07cf375ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 29 Mar 2017 15:51:45 +0200 Subject: [PATCH] [IMP] sale: improve link in quotations email Currently the link is always the website link once website_portal or website_quote is installed. However it is better to use the generic /mail/view controller that chooses the right redirection depending on the user trying to access the document. This commit also fixes redirection in website_quote that is always redirecting to the front-end. Classic users should land on the backend. Indeed seeing the front-end page is rarely interesting for them. --- addons/sale/data/mail_template_data.xml | 4 ++-- addons/website_quote/models/sale_order.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/sale/data/mail_template_data.xml b/addons/sale/data/mail_template_data.xml index 5208b4698bf..72b2dae500c 100644 --- a/addons/sale/data/mail_template_data.xml +++ b/addons/sale/data/mail_template_data.xml @@ -16,10 +16,10 @@ Dear ${object.partner_id.name} % 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 doc_name = 'quotation' if object.state in ('draft', 'sent') else 'order confirmation' % set access_name = is_online and object.template_id and 'Accept and pay %s online' % doc_name or 'View %s' % doc_name -% set access_url = is_online and access_action['url'] or '' +% set access_url = is_online and '/mail/view?model=sale.order&res_id=%d' % (object.id) or '' % if object.partner_id.parent_id: (${object.partner_id.parent_id.name}) diff --git a/addons/website_quote/models/sale_order.py b/addons/website_quote/models/sale_order.py index d84b6b6766b..1737b109f67 100644 --- a/addons/website_quote/models/sale_order.py +++ b/addons/website_quote/models/sale_order.py @@ -170,7 +170,7 @@ class SaleOrder(models.Model): def get_access_action(self): """ Instead of the classic form view, redirect to the online quote if it exists. """ self.ensure_one() - if not self.template_id: + if not self.template_id or (not self.env.user.share and not self.env.context.get('force_website')): return super(SaleOrder, self).get_access_action() return { 'type': 'ir.actions.act_url',