[FIX] sale_timesheet: set correct invoice_state on timesheeted sol
When generating an invoice for a SO with 2 SOL that have a timesheet service (1 SOL is timesheeted in August, the other is timesheeted in September) and we request the invoice for the period of August only, the SOL for September is incorrectly set to state "Nothing to Invoice", instead of staying in state "To Invoice". This is due to the fact that when we inspect the SOL to invoice, those that are not in the domain (here the SOL in September is not in the time domain of August), we set it's qty_to_invoice to 0, so it doesn't get invoiced, but this is a computed field, which sets the line invoice_state to "Nothing to invoice". The proposed fix is to reset the invoice_state of the lines that are not validated by the domain to the state before setting the field qty_to_invoice to 0. Affected versions: - 15.0 - saas-15.2 - saas-15.3 - master opw-2969641 closes odoo/odoo#100978 X-original-commit: 50b81adb3ea13db33bf1375b7038b6cc3546ec86 Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com> Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
This commit is contained in:
@@ -271,7 +271,13 @@ class SaleOrderLine(models.Model):
|
||||
mapping = lines_by_timesheet.sudo()._get_delivered_quantity_by_analytic(domain)
|
||||
|
||||
for line in lines_by_timesheet:
|
||||
line.qty_to_invoice = mapping.get(line.id, 0.0)
|
||||
qty_to_invoice = mapping.get(line.id, 0.0)
|
||||
if qty_to_invoice:
|
||||
line.qty_to_invoice = qty_to_invoice
|
||||
else:
|
||||
prev_inv_status = line.invoice_status
|
||||
line.qty_to_invoice = qty_to_invoice
|
||||
line.invoice_status = prev_inv_status
|
||||
|
||||
def _get_action_per_item(self):
|
||||
""" Get action per Sales Order Item
|
||||
|
||||
@@ -455,6 +455,8 @@ class TestSaleTimesheet(TestCommonSaleTimesheet):
|
||||
wizard.create_invoices()
|
||||
|
||||
self.assertTrue(sale_order.invoice_ids, 'One invoice should be created because the timesheet logged is between the period defined in wizard')
|
||||
self.assertTrue(all(line.invoice_status == "to invoice" for line in sale_order.order_line if line.qty_delivered != line.qty_invoiced),
|
||||
"All lines that still have some quantity to be invoiced should have an invoice status of 'to invoice', regardless if they were considered for previous invoicing, but didn't belong to the timesheet domain")
|
||||
|
||||
invoice = sale_order.invoice_ids[0]
|
||||
self.assertEqual(so_line_deliver_global_project.qty_invoiced, timesheet1.unit_amount)
|
||||
|
||||
Reference in New Issue
Block a user