[FIX] sale_timesheet: Multicompany invoices with timesheet

- Assuming a sale order invoiced in a different company.
  The sale order line's invoice_lines fields will be empty, which causes issues with sale_timesheet.
  The code assumes that if the sale order line invoice status is set to 'invoice', it has at least one invoice line, which is not true.
  This patch address a fix for this issue.
This commit is contained in:
tbe-odoo
2018-02-28 17:19:22 +01:00
parent f4262e1a36
commit 49255e7d76
+1 -1
View File
@@ -136,7 +136,7 @@ class AccountAnalyticLine(models.Model):
values['timesheet_invoice_type'] = 'billable_fixed'
# if the so line is already invoiced, and the delivered qty is still smaller than the ordered, then link the timesheet to the invoice
if so_line.invoice_status == 'invoiced':
values['timesheet_invoice_id'] = so_line.invoice_lines[0].invoice_id.id
values['timesheet_invoice_id'] = so_line.invoice_lines and so_line.invoice_lines[0].invoice_id.id
elif so_line.product_id.invoice_policy == 'order' and so_line.product_id.service_type != 'timesheet':
values['timesheet_invoice_type'] = 'billable_fixed'