Skip to content
Permalink
Browse files

[IMP] sale_timesheet: show all timesheets.

- in invoice and in timesheet tab show ordered and delivered timesheets.
  • Loading branch information...
pka-odoo committed Apr 12, 2019
1 parent 61ef388 commit 47f1d8d4904d013b429bb7f3c241ff8431ca6b7c
Showing with 13 additions and 14 deletions.
  1. +13 −14 addons/sale_timesheet/controllers/portal.py
@@ -14,32 +14,31 @@

class CustomerPortal(CustomerPortal):

def get_domain_my_timesheet(self):
return ['|', '&',
('partner_id', '=', request.env.user.partner_id.id),
('user_id', '=', request.env.user.id),
('timesheet_invoice_type', '!=', 'non_billable')]

def _prepare_portal_layout_values(self):
values = super(CustomerPortal, self)._prepare_portal_layout_values()

domain = ['&', '|', '&', ('timesheet_invoice_type', '=', 'billable_time'),
('timesheet_invoice_id', '!=', False),
('timesheet_invoice_type', '=', 'billable_fixed'),
('so_line', '!=', False)]

values['timesheet_count'] = request.env['account.analytic.line'].search_count(domain)
values['timesheet_count'] = request.env['account.analytic.line'].search_count(self.get_domain_my_timesheet())
return values

def _invoice_get_page_view_values(self, invoice, access_token, **kw):
values = super(CustomerPortal, self)._invoice_get_page_view_values(invoice, access_token, **kw)
timesheets = request.env['account.analytic.line'].search([('timesheet_invoice_id', '=', invoice.id)])
# add invoice related timesheets
if timesheets:
values['timesheets'] = timesheets

sale_order = invoice.mapped('invoice_line_ids.sale_line_ids.order_id')
values['timesheets'] = sale_order.mapped('timesheet_ids').filtered(lambda t: t.timesheet_invoice_type != 'non_billable')

return values

@http.route(['/my/timesheets', '/my/timesheets/page/<int:page>'], type='http', auth="user", website=True)
def portal_my_timesheets(self, page=1, sortby=None, filterby=None, search=None, search_in='all', groupby='project', **kw):
values = self._prepare_portal_layout_values()
domain = ['&', '|', '&', ('timesheet_invoice_type', '=', 'billable_time'),
('timesheet_invoice_id', '!=', False),
('timesheet_invoice_type', '=', 'billable_fixed'),
('so_line', '!=', False)]

domain = self.get_domain_my_timesheet()

searchbar_sortings = {
'date': {'label': _('Newest'), 'order': 'date desc'},

0 comments on commit 47f1d8d

Please sign in to comment.
You can’t perform that action at this time.