From 49255e7d76ef13dec182e50cb356466243aef665 Mon Sep 17 00:00:00 2001 From: tbe-odoo Date: Wed, 28 Feb 2018 17:19:22 +0100 Subject: [PATCH] [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. --- addons/sale_timesheet/models/account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index 27d45b22677..db7d288ab18 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -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'