Skip to content
Snippets Groups Projects
Commit 67fe2c41 authored by Dawn Hwang's avatar Dawn Hwang
Browse files

[FIX] sale_timesheet: Check for so_line before unlinking invoice lines


Steps to reproduce:
 1. Create an SO with billable timesheet entries
 2. Create an invoice
 3. If using enterprise, first cancel the invoice and reset the timesheet
  entries back to draft, then set the invoice back to draft
 4. Remove the sale order items from the timesheet entries
 5. Remove the invoice line associated with the timesheet entries

Current behavior:
 - Throws an error since the so_line value from read_group is now
   False and is not subscriptable

Expected behavior:
 - Removes the invoice lines

Fix:
 - Check that the so_line is not False before continuing with the logic

closes odoo/odoo#133864

X-original-commit: dde30798
Signed-off-by: default avatarXavier Bol (xbo) <xbo@odoo.com>
parent 2f49ec86
Branches
Tags
No related merge requests found
......@@ -124,7 +124,7 @@ class AccountMoveLine(models.Model):
timesheet_ids = []
for timesheet in timesheet_read_group:
move_id = timesheet['timesheet_invoice_id'][0]
if timesheet['so_line'][0] in sale_line_ids_per_move[move_id].ids:
if timesheet['so_line'] and timesheet['so_line'][0] in sale_line_ids_per_move[move_id].ids:
timesheet_ids += timesheet['ids']
self.sudo().env['account.analytic.line'].browse(timesheet_ids).write({'timesheet_invoice_id': False})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment