From 802eba2450207f056d21c0aee1399c388c38d139 Mon Sep 17 00:00:00 2001 From: Pierre Verkest Date: Sun, 22 Sep 2024 22:23:41 +0200 Subject: [PATCH] [FIX] account_move_cutoff: while using full refund wizard action_post is not called better to overload _post on account.move model --- account_move_cutoff/models/account_move.py | 4 ++-- .../tests/test_account_invoice_cutoff.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) 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..3a7eff6138a 100644 --- a/account_move_cutoff/tests/test_account_invoice_cutoff.py +++ b/account_move_cutoff/tests/test_account_invoice_cutoff.py @@ -538,3 +538,15 @@ 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) + )