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..4b324b7254 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 = rec.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, 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: