diff --git a/account_move_cutoff/models/account_move.py b/account_move_cutoff/models/account_move.py index acd5bee8d09..66f3a5efdab 100644 --- a/account_move_cutoff/models/account_move.py +++ b/account_move_cutoff/models/account_move.py @@ -41,8 +41,8 @@ def button_draft(self): self.cutoff_entry_ids.with_context(force_delete=True).unlink() return res - def action_post(self): - result = super().action_post() + def _post(self, *args, **kwargs): + result = super()._post(*args, **kwargs) for move, lines in self._get_deferrable_lines(): move._create_cutoff_entries(lines) diff --git a/account_move_cutoff/tests/test_account_invoice_cutoff.py b/account_move_cutoff/tests/test_account_invoice_cutoff.py index 8440acfcbd8..fcc5e1ad27b 100644 --- a/account_move_cutoff/tests/test_account_invoice_cutoff.py +++ b/account_move_cutoff/tests/test_account_invoice_cutoff.py @@ -538,3 +538,16 @@ def test_account_invoice_cutoff_monthly_factor_prorata(self): 255.0, 2, ) + + def test_reverse_moves_reverse_deffered(self): + + with freeze_time("2023-01-15"): + self.invoice.action_post() + self.assertTrue(len(self.invoice.cutoff_entry_ids)>0) + refund = self.invoice._reverse_moves(cancel=True) + + self.assertEqual(refund.state, "posted") + self.assertEqual( + len(self.invoice.cutoff_entry_ids), + len(refund.cutoff_entry_ids) + ) \ No newline at end of file