[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
This commit is contained in:
Nicolas Lempereur
2016-11-23 09:32:18 +01:00
parent 6a18e31cee
commit 54d091448b
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
<field name="lang">${object.partner_id.lang}</field>
<field name="body_html"><![CDATA[
<p>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
@@ -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: