From a460edd896a4c3aa357ec7276b4532d85bb453f8 Mon Sep 17 00:00:00 2001 From: Maximilien TANTIN Date: Thu, 5 Sep 2024 11:35:53 +0200 Subject: [PATCH 1/3] [FIX][16.0][contract] Fix issue on last_date_invoice field on multiple contract lines --- contract/models/contract.py | 2 +- contract/models/contract_line.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/contract/models/contract.py b/contract/models/contract.py index 5b2b0ab596..b02e95a78c 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -575,7 +575,7 @@ def _prepare_recurring_invoices_values(self, date_ref=False): ) invoices_values.append(invoice_vals) # Force the recomputation of journal items - contract_lines._update_recurring_next_date() + contract_lines._update_recurring_next_date(date_ref) return invoices_values def recurring_create_invoice(self): diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py index 80034f6062..7c026898a4 100644 --- a/contract/models/contract_line.py +++ b/contract/models/contract_line.py @@ -603,11 +603,18 @@ def _insert_markers(self, first_date_invoiced, last_date_invoiced): name = name.replace("#END#", last_date_invoiced.strftime(date_format)) return name - def _update_recurring_next_date(self): + def _update_recurring_next_date(self, invoicing_date=False): # FIXME: Change method name according to real updated field # e.g.: _update_last_date_invoiced() for rec in self: last_date_invoiced = rec.next_period_date_end + if invoicing_date: + last_date_invoiced = self.get_next_period_date_end( + invoicing_date, + rec.recurring_rule_type, + rec.recurring_interval, + rec.date_end, + ) rec.write( { "last_date_invoiced": last_date_invoiced, From 5943315df1460e3fa5020e146b25eef19a5d69c6 Mon Sep 17 00:00:00 2001 From: Maximilien TANTIN Date: Thu, 5 Sep 2024 13:54:39 +0200 Subject: [PATCH 2/3] Update contract/models/contract_line.py Co-authored-by: Denis Roussel (ACSONE) --- contract/models/contract_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contract/models/contract_line.py b/contract/models/contract_line.py index 7c026898a4..4b324b7254 100644 --- a/contract/models/contract_line.py +++ b/contract/models/contract_line.py @@ -609,7 +609,7 @@ def _update_recurring_next_date(self, invoicing_date=False): for rec in self: last_date_invoiced = rec.next_period_date_end if invoicing_date: - last_date_invoiced = self.get_next_period_date_end( + last_date_invoiced = rec.get_next_period_date_end( invoicing_date, rec.recurring_rule_type, rec.recurring_interval, From c7fed3439a1c00ab0e0b23cd8d74a48e3850de54 Mon Sep 17 00:00:00 2001 From: Julien Ortet Date: Thu, 28 Nov 2024 10:05:51 +0100 Subject: [PATCH 3/3] [FIX] fix compute next period date end dependencies --- contract/models/contract_recurrency_mixin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/contract/models/contract_recurrency_mixin.py b/contract/models/contract_recurrency_mixin.py index aebc76c3f2..a4ae0c4f30 100644 --- a/contract/models/contract_recurrency_mixin.py +++ b/contract/models/contract_recurrency_mixin.py @@ -124,8 +124,6 @@ def _compute_next_period_date_start(self): "recurring_invoicing_offset", "recurring_rule_type", "recurring_interval", - "date_end", - "recurring_next_date", ) def _compute_next_period_date_end(self): for rec in self: