diff options
| author | Thibault Delavallée <tde@odoo.com> | 2017-09-04 18:12:26 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2017-09-06 10:49:03 +0200 |
| commit | e6120eb7d6a8ef0fc0f88b3ccd001b722bee73d3 (patch) | |
| tree | 1db71a8c572a10eac81e6bcc851f3e72eff35a6a /addons | |
| parent | 1fad5698fc67bb4bbcc6df07828b05ac677099c6 (diff) | |
[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;
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/controllers/__init__.py | 1 | ||||
| -rw-r--r-- | addons/account/controllers/mail.py | 29 | ||||
| -rw-r--r-- | addons/account/views/account_portal_templates.xml | 41 |
3 files changed, 47 insertions, 24 deletions
diff --git a/addons/account/controllers/__init__.py b/addons/account/controllers/__init__.py index 903b755e71e..e5a6112c48f 100644 --- a/addons/account/controllers/__init__.py +++ b/addons/account/controllers/__init__.py @@ -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 diff --git a/addons/account/controllers/mail.py b/addons/account/controllers/mail.py new file mode 100644 index 00000000000..f30c69e21ba --- /dev/null +++ b/addons/account/controllers/mail.py @@ -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) diff --git a/addons/account/views/account_portal_templates.xml b/addons/account/views/account_portal_templates.xml index c4c7abc140e..fca47c3a50c 100644 --- a/addons/account/views/account_portal_templates.xml +++ b/addons/account/views/account_portal_templates.xml @@ -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> |
