|
|
@ -24,66 +24,77 @@ from collections import OrderedDict |
|
|
|
|
|
|
|
_logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
# class Kalachakra_PortalAccount(CustomerPortal): |
|
|
|
# @http.route(['/my/invoices', '/my/invoices/page/<int:page>'], type='http', auth="user", website=True) |
|
|
|
# def kalachakra_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': _('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'}, |
|
|
|
# } |
|
|
|
# # default sort by order |
|
|
|
# if not sortby: |
|
|
|
# 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'] |
|
|
|
|
|
|
|
# if date_begin and date_end: |
|
|
|
# domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] |
|
|
|
|
|
|
|
# # count for pager |
|
|
|
# invoice_count = AccountInvoice.search_count(domain) |
|
|
|
|
|
|
|
# # pager |
|
|
|
# pager = portal_pager( |
|
|
|
# url="/my/invoices", |
|
|
|
# url_args={'date_begin': date_begin, 'date_end': date_end, 'sortby': sortby}, |
|
|
|
# total=invoice_count, |
|
|
|
# page=page, |
|
|
|
# step=self._items_per_page |
|
|
|
# ) |
|
|
|
# # content according to pager and archive selected |
|
|
|
# invoices = AccountInvoice.search(domain, order=order, limit=self._items_per_page, offset=pager['offset']) |
|
|
|
|
|
|
|
# request.session['my_invoices_history'] = invoices.ids[:100] |
|
|
|
|
|
|
|
# values.update({ |
|
|
|
# 'date': date_begin, |
|
|
|
# 'invoices': invoices, |
|
|
|
# 'page_name': 'invoice', |
|
|
|
# 'pager': pager, |
|
|
|
# '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) |
|
|
|
class Kalachakra_PortalAccount(CustomerPortal): |
|
|
|
@http.route(['/my/invoices', '/my/invoices/page/<int:page>'], type='http', auth="user", website=True) |
|
|
|
def kalachakra_portal_my_invoices(self, page=1, date_begin=None, date_end=None, sortby=None, filterby=None, **kw): |
|
|
|
values = self._prepare_portal_layout_values() |
|
|
|
#KALACHAKRA : on affiche que les factures de l'utilisateur ( idem pour les admins) |
|
|
|
AccountInvoice = request.env['account.move'].search([('user_id','=',int(request.env.context.get('uid')))]) |
|
|
|
|
|
|
|
domain = [('move_type', 'in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund', 'out_receipt', 'in_receipt'))] |
|
|
|
|
|
|
|
searchbar_sortings = { |
|
|
|
'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'}, |
|
|
|
} |
|
|
|
# default sort by order |
|
|
|
if not sortby: |
|
|
|
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'] |
|
|
|
|
|
|
|
if date_begin and date_end: |
|
|
|
domain += [('create_date', '>', date_begin), ('create_date', '<=', date_end)] |
|
|
|
|
|
|
|
# count for pager |
|
|
|
invoice_count = AccountInvoice.search_count(domain) |
|
|
|
|
|
|
|
# pager |
|
|
|
pager = portal_pager( |
|
|
|
url="/my/invoices", |
|
|
|
url_args={'date_begin': date_begin, 'date_end': date_end, 'sortby': sortby}, |
|
|
|
total=invoice_count, |
|
|
|
page=page, |
|
|
|
step=self._items_per_page |
|
|
|
) |
|
|
|
# content according to pager and archive selected |
|
|
|
invoices = AccountInvoice.search(domain, order=order, limit=self._items_per_page, offset=pager['offset']) |
|
|
|
|
|
|
|
request.session['my_invoices_history'] = invoices.ids[:100] |
|
|
|
|
|
|
|
values.update({ |
|
|
|
'date': date_begin, |
|
|
|
'invoices': invoices, |
|
|
|
'page_name': 'invoice', |
|
|
|
'pager': pager, |
|
|
|
'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) |
|
|
|
|
|
|
|
def _prepare_home_portal_values(self, counters): |
|
|
|
values = super()._prepare_home_portal_values(counters) |
|
|
|
if 'invoice_count' in counters: |
|
|
|
#KALACHAKRA : on compte que les factures de l'utilisateur ( idem pour les admins) |
|
|
|
invoice_count = request.env['account.move'].search_count([('user_id','=',int(request.env.context.get('uid'))), |
|
|
|
('move_type', 'in', ('out_invoice', 'in_invoice', 'out_refund', 'in_refund', 'out_receipt', 'in_receipt')), |
|
|
|
]) if request.env['account.move'].check_access_rights('read', raise_exception=False) else 0 |
|
|
|
values['invoice_count'] = invoice_count |
|
|
|
return values |
|
|
|
|
|
|
|
class KalaAuthSignupHome(Home): |
|
|
|
@http.route('/web/signup', type='http', auth='public', website=True, sitemap=False) |
|
|
|