Skip to content

Commit 7c04445

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 c5bb14c commit 7c04445

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
@@ -553,3 +553,28 @@ def test_confirm_invoice_intercompany_disabled(self):
553553
[("auto_invoice_id", "=", self.invoice_company_a.id)]
554554
)
555555
self.assertFalse(invoices)
556+
557+
def test_invoice_full_refund(self):
558+
# Confirm the invoice for company A
559+
self.invoice_company_a.with_user(self.user_company_a.id).action_post()
560+
# Open the account move reversal wizard
561+
# We use a form to pass the context properly to the depends_context move_ids field
562+
context = {
563+
"active_model": "account.move",
564+
"active_ids": self.invoice_company_a.ids,
565+
}
566+
with Form(
567+
self.env["account.move.reversal"]
568+
.with_context(**context)
569+
.with_user(self.user_company_a.id)
570+
) as wizard_form:
571+
wizard_form.refund_method = "cancel"
572+
wizard = wizard_form.save()
573+
# Create the reversal move.
574+
wizard.reverse_moves()
575+
self.assertTrue(wizard.new_move_ids)
576+
self.assertTrue(
577+
self.env["account.move"]
578+
.with_user(self.user_company_b)
579+
.search([("auto_invoice_id", "=", wizard.new_move_ids.id)])
580+
)

0 commit comments

Comments
 (0)