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,