[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.
This commit is contained in:
Thibault Delavallée
2017-04-25 14:10:54 +02:00
parent bf2f6f9264
commit b49da62365
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -16,10 +16,10 @@
<field name="body_html"><![CDATA[
<p>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:
(<i>${object.partner_id.parent_id.name}</i>)
+1 -1
View File
@@ -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',