diff --git a/account_invoice_inter_company/models/account_move.py b/account_invoice_inter_company/models/account_move.py index bc856fcb224..f9da2ff9c5f 100644 --- a/account_invoice_inter_company/models/account_move.py +++ b/account_invoice_inter_company/models/account_move.py @@ -40,9 +40,9 @@ def _find_company_from_invoice_partner(self): ) return company or False - def action_post(self): + def _post(self, soft=True): """Validated invoice generate cross invoice base on company rules""" - res = super().action_post() + res = super()._post(soft=soft) # Intercompany account entries or receipts aren't supported supported_types = {"out_invoice", "in_invoice", "out_refund", "in_refund"} for src_invoice in self.filtered(lambda x: x.move_type in supported_types): diff --git a/account_invoice_inter_company/tests/test_inter_company_invoice.py b/account_invoice_inter_company/tests/test_inter_company_invoice.py index 1d9fa690bf7..4cb543f6988 100644 --- a/account_invoice_inter_company/tests/test_inter_company_invoice.py +++ b/account_invoice_inter_company/tests/test_inter_company_invoice.py @@ -553,3 +553,28 @@ def test_confirm_invoice_intercompany_disabled(self): [("auto_invoice_id", "=", self.invoice_company_a.id)] ) self.assertFalse(invoices) + + def test_invoice_full_refund(self): + # Confirm the invoice for company A + self.invoice_company_a.with_user(self.user_company_a.id).action_post() + # Open the account move reversal wizard + # We use a form to pass the context properly to the depends_context move_ids field + context = { + "active_model": "account.move", + "active_ids": self.invoice_company_a.ids, + } + with Form( + self.env["account.move.reversal"] + .with_context(**context) + .with_user(self.user_company_a.id) + ) as wizard_form: + wizard_form.refund_method = "cancel" + wizard = wizard_form.save() + # Create the reversal move. + wizard.reverse_moves() + self.assertTrue(wizard.new_move_ids) + self.assertTrue( + self.env["account.move"] + .with_user(self.user_company_b) + .search([("auto_invoice_id", "=", wizard.new_move_ids.id)]) + )