[IMP] account: improve invoice page view on customer portal
* keep query on pdf link so that customers have access to the pdf when using the access token instead of having an access rights error; * add redirect to record override that allow to take into account /mail/view links containing an access token for invoices like what is already supported for sale orders; * improve action buttons display; * reduce headers and better display invoice name and customer address;
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import mail
|
||||
from . import portal
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import werkzeug
|
||||
|
||||
from odoo.addons.mail.controllers.main import MailController
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.http import request
|
||||
from odoo.tools.misc import consteq
|
||||
|
||||
|
||||
class MailController(MailController):
|
||||
|
||||
def _redirect_to_record(cls, model, res_id, access_token=None):
|
||||
# If the current user doesn't have access to the invoice, but provided
|
||||
# a valid access token, redirect him to the front-end view.
|
||||
if model == 'account.invoice' and res_id and access_token:
|
||||
uid = request.session.uid or request.env.ref('base.public_user').id
|
||||
record_sudo = request.env[model].sudo().browse(res_id).exists()
|
||||
try:
|
||||
record_sudo.sudo(uid).check_access_rights('read')
|
||||
record_sudo.sudo(uid).check_access_rule('read')
|
||||
except AccessError:
|
||||
if record_sudo.access_token and consteq(record_sudo.access_token, access_token):
|
||||
record_action = record_sudo.with_context(
|
||||
force_website=True).get_access_action(uid)
|
||||
if record_action['type'] == 'ir.actions.act_url':
|
||||
return werkzeug.utils.redirect(record_action['url'])
|
||||
return super(MailController, cls)._redirect_to_record(model, res_id, access_token=access_token)
|
||||
@@ -80,19 +80,10 @@
|
||||
<span t-esc="invoice.number"/>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-6 col-xs-12 hidden-print" id="action_buttons">
|
||||
<ul class="list-inline pull-right">
|
||||
<li class="o_download_button">
|
||||
<a target="_blank" t-att-href="'/my/invoices/pdf/%s' % invoice.id" title="Download">
|
||||
<i class="fa fa-download fa-2x" aria-hidden="true"/>
|
||||
</a>
|
||||
</li>
|
||||
<li class="o_print_button">
|
||||
<a id="print_iframe" title="Print">
|
||||
<i class="fa fa-print fa-2x" aria-hidden="true"/>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="col-md-6 col-sm-6 col-xs-12 hidden-print" id="o_portal_account_actions">
|
||||
<a target="_blank" t-att-href="'/my/invoices/pdf/%s?%s' % (invoice.id, keep_query())" class="pull-right" title="Download">
|
||||
<i class="fa fa-download fa-2x" aria-hidden="true"/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -109,23 +100,25 @@
|
||||
|
||||
<template id="portal_invoice_report" name="Invoice Portal Report">
|
||||
<div class="row">
|
||||
<div class="col-xs-5 col-xs-offset-7">
|
||||
<div class="col-xs-7">
|
||||
<h4>
|
||||
<span t-if="invoice.type == 'out_invoice' and (invoice.state == 'open' or invoice.state == 'paid')">Invoice</span>
|
||||
<span t-if="invoice.type == 'out_invoice' and invoice.state == 'draft'">Draft Invoice</span>
|
||||
<span t-if="invoice.type == 'out_invoice' and invoice.state == 'cancel'">Cancelled Invoice</span>
|
||||
<span t-if="invoice.type == 'out_refund'">Credit Note</span>
|
||||
<span t-if="invoice.type == 'in_refund'">Vendor Credit Note</span>
|
||||
<span t-if="invoice.type == 'in_invoice'">Vendor Bill</span>
|
||||
<span t-field="invoice.number"/>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="col-xs-5">
|
||||
<strong>Customer Address</strong>
|
||||
<address t-field="invoice.partner_id"
|
||||
t-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": True}' />
|
||||
<div t-if="invoice.partner_id.vat" class="mt16">VAT: <span t-field="invoice.partner_id.vat"/></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>
|
||||
<span t-if="invoice.type == 'out_invoice' and (invoice.state == 'open' or invoice.state == 'paid')">Invoice</span>
|
||||
<span t-if="invoice.type == 'out_invoice' and invoice.state == 'draft'">Draft Invoice</span>
|
||||
<span t-if="invoice.type == 'out_invoice' and invoice.state == 'cancel'">Cancelled Invoice</span>
|
||||
<span t-if="invoice.type == 'out_refund'">Credit Note</span>
|
||||
<span t-if="invoice.type == 'in_refund'">Vendor Credit Note</span>
|
||||
<span t-if="invoice.type == 'in_invoice'">Vendor Bill</span>
|
||||
<span t-field="invoice.number"/>
|
||||
</h2>
|
||||
|
||||
<div class="row mt32 mb32">
|
||||
<div class="col-xs-2" t-if="invoice.name">
|
||||
<strong>Description:</strong>
|
||||
|
||||
Reference in New Issue
Block a user