[IMP] account: support error, warning and success codes in customer portal

Purpose is to allow to display error, warning or success messages based
on some user action like payment. This is done using kwargs in the invoice
view route. Codes are added in URL and message display has to be managed
in the template itself. Inheriting modules and/or new features will have
to add their specific message according to the error, warning or success
messages they want to support.
This commit is contained in:
Thibault Delavallée
2017-09-06 10:49:03 +02:00
parent 2d4c8103f9
commit 1fad5698fc
2 changed files with 28 additions and 0 deletions
+7
View File
@@ -45,6 +45,13 @@ class PortalAccount(CustomerPortal):
}
if access_token:
values['no_breadcrumbs'] = True
if kwargs.get('error'):
values['error'] = kwargs['error']
if kwargs.get('warning'):
values['warning'] = kwargs['warning']
if kwargs.get('success'):
values['success'] = kwargs['success']
return values
@http.route(['/my/invoices', '/my/invoices/page/<int:page>'], type='http', auth="user", website=True)
@@ -97,6 +97,8 @@
</div>
</div>
<div class="panel-body">
<t t-if="error or warning" t-call="account.portal_invoice_error"/>
<t t-if="success and (not error and not warning)" t-call="account.portal_invoice_success"/>
<t t-call="account.portal_invoice_report"/>
</div>
</div>
@@ -261,4 +263,23 @@
<span t-field="invoice.fiscal_position_id.note"/>
</p>
</template>
<template id="portal_invoice_error" name="Invoice error/warning display">
<div class="row">
<div t-att-class="'col-md-6 col-md-offset-3 text-center alert alert-dismissable %s' % ('alert-danger' if error else 'alert-warning')">
<a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
<t t-if="error == 'generic'" name="generic">
There was an error processing this page.
</t>
</div>
</div>
</template>
<template id="portal_invoice_success" name="Invoice success display">
<div class="row">
<div class="col-md-6 col-md-offset-3 text-center alert alert-dismissable alert-success">
<a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
</div>
</div>
</template>
</odoo>