summaryrefslogtreecommitdiff
path: root/addons/account/controllers
diff options
context:
space:
mode:
authorRavi Singh <ras@odoo.com>2020-03-25 10:03:21 +0000
committerRavi Singh <ras@odoo.com>2020-04-16 06:21:51 +0000
commit6ef2e1d3ec7c4f19dbdc73b76eb09ff2d5fcb192 (patch)
treea2973a8e51d9148ef4cb0086e47c16541b26bec1 /addons/account/controllers
parent9bfce9a99991a0316abee31d1bbce504f82910ec (diff)
[IMP] account: invoice view improvement inside portal.
In this commit- we have added filter options like bills and invoices in for invoice view(portal side) . In addition, we have changed sort by option's string from 'Invoice Date' to 'Date'. task-2124829 Closes #48402
Diffstat (limited to 'addons/account/controllers')
-rw-r--r--addons/account/controllers/portal.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/addons/account/controllers/portal.py b/addons/account/controllers/portal.py
index e9f0daddfef..5f32d2fb13e 100644
--- a/addons/account/controllers/portal.py
+++ b/addons/account/controllers/portal.py
@@ -4,6 +4,7 @@
from odoo import http, _
from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager
from odoo.exceptions import AccessError, MissingError
+from collections import OrderedDict
from odoo.http import request
@@ -29,14 +30,14 @@ class PortalAccount(CustomerPortal):
return self._get_page_view_values(invoice, access_token, values, 'my_invoices_history', False, **kwargs)
@http.route(['/my/invoices', '/my/invoices/page/<int:page>'], type='http', auth="user", website=True)
- def portal_my_invoices(self, page=1, date_begin=None, date_end=None, sortby=None, **kw):
+ def portal_my_invoices(self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, **kw):
values = self._prepare_portal_layout_values()
AccountInvoice = request.env['account.move']
domain = [('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))]
searchbar_sortings = {
- 'date': {'label': _('Invoice Date'), 'order': 'invoice_date desc'},
+ 'date': {'label': _('Date'), 'order': 'invoice_date desc'},
'duedate': {'label': _('Due Date'), 'order': 'invoice_date_due desc'},
'name': {'label': _('Reference'), 'order': 'name desc'},
'state': {'label': _('Status'), 'order': 'state'},
@@ -46,6 +47,16 @@ class PortalAccount(CustomerPortal):
sortby = 'date'
order = searchbar_sortings[sortby]['order']
+ searchbar_filters = {
+ 'all': {'label': _('All'), 'domain': [('move_type', 'in', ['in_invoice', 'out_invoice'])]},
+ 'invoices': {'label': _('Invoices'), 'domain': [('move_type', '=', 'out_invoice')]},
+ 'bills': {'label': _('Bills'), 'domain': [('move_type', '=', 'in_invoice')]},
+ }
+ # default filter by value
+ if not filterby:
+ filterby = 'all'
+ domain += searchbar_filters[filterby]['domain']
+
archive_groups = self._get_archive_groups('account.move', domain)
if date_begin and date_end:
domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)]
@@ -73,6 +84,8 @@ class PortalAccount(CustomerPortal):
'default_url': '/my/invoices',
'searchbar_sortings': searchbar_sortings,
'sortby': sortby,
+ 'searchbar_filters': OrderedDict(sorted(searchbar_filters.items())),
+ 'filterby':filterby,
})
return request.render("account.portal_my_invoices", values)