[IMP] sale: add download link on customer portal to access the order report
This commit also adds a route to have the sale order report. It supports access token so that email links already enables the download of the pdf.
This commit is contained in:
@@ -176,3 +176,19 @@ class CustomerPortal(CustomerPortal):
|
||||
|
||||
values = self._order_get_page_view_values(order_sudo, access_token, **kw)
|
||||
return request.render("sale.portal_order_page", values)
|
||||
|
||||
@http.route(['/my/orders/pdf/<int:order_id>'], type='http', auth="public", website=True)
|
||||
def portal_order_report(self, order_id, access_token=None, **kw):
|
||||
try:
|
||||
order_sudo = self._order_check_access(order_id, access_token)
|
||||
except AccessError:
|
||||
return request.redirect('/my')
|
||||
|
||||
# print report as sudo, since it require access to taxes, payment term, ... and portal
|
||||
# does not have those access rights.
|
||||
pdf = request.env.ref('sale.action_report_saleorder').sudo().render_qweb_pdf([order_sudo.id])[0]
|
||||
pdfhttpheaders = [
|
||||
('Content-Type', 'application/pdf'),
|
||||
('Content-Length', len(pdf)),
|
||||
]
|
||||
return request.make_response(pdf, headers=pdfhttpheaders)
|
||||
|
||||
@@ -136,17 +136,18 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h4>
|
||||
<t t-call='portal.record_pager'/>
|
||||
<t t-if="order.state == 'sent'">
|
||||
Quotation
|
||||
</t>
|
||||
<t t-if="order.state != 'sent'">
|
||||
Order
|
||||
</t>
|
||||
<span t-esc="order.name"/>
|
||||
</h4>
|
||||
<div class="col-md-6">
|
||||
<h4>
|
||||
<t t-call='portal.record_pager'/>
|
||||
<t t-if="order.state == 'sent'">Quotation</t>
|
||||
<t t-if="order.state != 'sent'">Order</t>
|
||||
<span t-esc="order.name"/>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-6 col-xs-12 hidden-print" id="o_portal_order_actions">
|
||||
<a target="_blank" t-att-href="'/my/orders/pdf/%s?%s' % (order.id, keep_query())" class="pull-right" title="Download">
|
||||
<i class="fa fa-download fa-2x" aria-hidden="true"/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user