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..f667c4d396e 100644 --- a/account_invoice_inter_company/tests/test_inter_company_invoice.py +++ b/account_invoice_inter_company/tests/test_inter_company_invoice.py @@ -3,7 +3,7 @@ # Copyright 2020 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo import _ +from odoo import _, Command from odoo.exceptions import UserError, ValidationError from odoo.tests import tagged from odoo.tests.common import Form, TransactionCase @@ -553,3 +553,25 @@ 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 of 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_line_ids field + # context = { + # 'active_model': 'account.move.line', + # 'active_ids': move_with_tax.line_ids[0].ids + # } + with Form( + self.env["account.move.reversal"].with_user(self.user_company_a.id) + ) as wizard_form: + wizard_form.move_ids = [Command.set(self.invoice_company_a.ids)] + 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)] + )