Skip to content

Commit

Permalink
[FIX] account_invoice_inter_company : creating a credit note should g…
Browse files Browse the repository at this point in the history
…enerate a supplier refund in the other company

Fixes OCA#736
  • Loading branch information
metaminux committed Dec 11, 2024
1 parent c5bb14c commit 38f2a70
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)]
)

0 comments on commit 38f2a70

Please sign in to comment.