[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:
@@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user