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 33805bc commit 7ea62c9906c812707c162fcb7e4394cd20824dd2
Showing with 16 additions and 16 deletions.
  1. +13 −14 addons/sale_timesheet/controllers/portal.py
  2. +3 −2 addons/sale_timesheet/models/account.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('tasks_ids.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'},
@@ -26,13 +26,14 @@ def _default_sale_line_domain(self):
def _compute_timesheet_invoice_type(self):
for timesheet in self:
if timesheet.project_id: # AAL will be set to False
invoice_type = 'non_billable_project' if not timesheet.task_id else 'non_billable'
if not timesheet.task_id:
invoice_type = 'non_billable_project'
if timesheet.task_id and timesheet.so_line.product_id.type == 'service':
if timesheet.so_line.product_id.invoice_policy == 'delivery':
if timesheet.so_line.product_id.service_type == 'timesheet':
invoice_type = 'billable_time'
else:
invoice_type = 'billable_fixed'
invoice_type = 'non_billable'
elif timesheet.so_line.product_id.invoice_policy == 'order':
invoice_type = 'billable_fixed'
timesheet.timesheet_invoice_type = invoice_type

0 comments on commit 7ea62c9

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