Skip to content

Commit 41a8fcc

Browse files
committed
[FIX] account_invoice_inter_company : creating a credit note should generate a supplier refund in the other company
Fixes #736
1 parent 003cac0 commit 41a8fcc

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Diff for: account_invoice_inter_company/models/account_move.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def _find_company_from_invoice_partner(self):
4040
)
4141
return company or False
4242

43-
def action_post(self):
43+
def _post(self, soft=True):
4444
"""Validated invoice generate cross invoice base on company rules"""
45-
res = super().action_post()
45+
res = super()._post(soft=soft)
4646
# Intercompany account entries or receipts aren't supported
4747
supported_types = {"out_invoice", "in_invoice", "out_refund", "in_refund"}
4848
for src_invoice in self.filtered(lambda x: x.move_type in supported_types):

Diff for: account_invoice_inter_company/tests/test_inter_company_invoice.py

+25
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,31 @@ def _confirm_invoice_with_product(self):
541541
self.assertEqual(len(invoices), 1)
542542
return invoices
543543

544+
def test_invoice_full_refund(self):
545+
# Confirm the invoice for company A
546+
self.invoice_company_a.with_user(self.user_company_a.id).action_post()
547+
# Open the account move reversal wizard
548+
# We use a form to pass the context properly to the depends_context move_ids field
549+
context = {
550+
"active_model": "account.move",
551+
"active_ids": self.invoice_company_a.ids,
552+
}
553+
with Form(
554+
self.env["account.move.reversal"]
555+
.with_context(**context)
556+
.with_user(self.user_company_a.id)
557+
) as wizard_form:
558+
wizard_form.refund_method = "cancel"
559+
wizard = wizard_form.save()
560+
# Create the reversal move.
561+
wizard.reverse_moves()
562+
self.assertTrue(wizard.new_move_ids)
563+
self.assertTrue(
564+
self.env["account.move"]
565+
.with_user(self.user_company_b)
566+
.search([("auto_invoice_id", "=", wizard.new_move_ids.id)])
567+
)
568+
544569
def test_confirm_invoice_intercompany_disabled(self):
545570
# ensure the catalog is shared
546571
self.env.ref("product.product_comp_rule").write({"active": False})

0 commit comments

Comments
 (0)