Skip to content
Permalink
Browse files

[IMP] sale_timesheet: show ordered and delivered timesheets

  • Loading branch information...
pka-odoo committed Apr 15, 2019
1 parent b18e732 commit b495b229825eb3af05ec55d5bb0a4e002fb406f5
Showing with 8 additions and 8 deletions.
  1. +7 −7 addons/sale_timesheet/controllers/portal.py
  2. +1 −1 addons/sale_timesheet/models/account_invoice.py
@@ -15,7 +15,7 @@
class CustomerPortal(CustomerPortal):

def get_domain_my_timesheet(self):
return ['|', '&', ('user_id', '=', request.env.user.id), ('partner_id', '=', request.env.user.partner_id.id), ('so_line.invoice_status', 'in', ['invoiced', 'upselling'])]
return ['|', '&', ('user_id', '=', request.env.user.id), ('partner_id', '=', request.env.user.partner_id.id), ('timesheet_invoice_id', '!=', False)]

def _prepare_portal_layout_values(self):
values = super(CustomerPortal, self)._prepare_portal_layout_values()
@@ -26,14 +26,14 @@ def _prepare_portal_layout_values(self):
def _invoice_get_page_view_values(self, invoice, access_token, **kw):
values = super(CustomerPortal, self)._invoice_get_page_view_values(invoice, access_token, **kw)

sale_order = invoice.mapped('invoice_line_ids.sale_line_ids.order_id')
values['timesheets'] = sale_order.timesheet_ids or sale_order.mapped('tasks_ids.timesheet_ids')
timesheets = request.env['account.analytic.line'].search([('timesheet_invoice_id', '=', invoice.id)])
if timesheets:
values['timesheets'] = timesheets

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):
account_analytic_line_sudo = request.env['account.analytic.line']
values = self._prepare_portal_layout_values()

domain = self.get_domain_my_timesheet()
@@ -84,7 +84,7 @@ def portal_my_timesheets(self, page=1, sortby=None, filterby=None, search=None,
search_domain = OR([search_domain, [('name', 'ilike', search)]])
domain += search_domain

timesheet_count = account_analytic_line_sudo.search_count(domain)
timesheet_count = request.env['account.analytic.line'].search_count(domain)
# pager
pager = portal_pager(
url="/my/timesheets",
@@ -96,9 +96,9 @@ def portal_my_timesheets(self, page=1, sortby=None, filterby=None, search=None,

if groupby == 'project':
order = "project_id, %s" % order
timesheets = account_analytic_line_sudo.search(domain, order=order, limit=self._items_per_page, offset=pager['offset'])
timesheets = request.env['account.analytic.line'].search(domain, order=order, limit=self._items_per_page, offset=pager['offset'])
if groupby == 'project':
grouped_timesheets = [account_analytic_line_sudo.concat(*g) for k, g in groupbyelem(timesheets, itemgetter('project_id'))]
grouped_timesheets = [request.env['account.analytic.line'].concat(*g) for k, g in groupbyelem(timesheets, itemgetter('project_id'))]
else:
grouped_timesheets = [timesheets]

@@ -58,7 +58,7 @@ def create(self, values):
"""
invoice_line = super(AccountInvoiceLine, self).create(values)
if invoice_line.invoice_id.type == 'out_invoice' and invoice_line.invoice_id.state == 'draft':
sale_line_delivery = invoice_line.sale_line_ids.filtered(lambda sol: sol.product_id.invoice_policy == 'delivery' and sol.product_id.service_type == 'timesheet')
sale_line_delivery = invoice_line.sale_line_ids.filtered(lambda sol: sol.product_id.service_type == 'timesheet')
if sale_line_delivery:
domain = self._timesheet_domain_get_invoiced_lines(sale_line_delivery)
timesheets = self.env['account.analytic.line'].search(domain)

0 comments on commit b495b22

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