[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:
@@ -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>)
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user