Skip to content

Commit 7c29877

Browse files
metaminuxemiliesoutiras
authored andcommitted
[FIX] account_invoice_inter_company : creating a credit note should generate a supplier refund in the other company
Fixes #736
1 parent bc97b08 commit 7c29877

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
@@ -46,9 +46,9 @@ def _set_intercompany_supplier_invoice_ref(self):
4646
if not supplier_invoice.ref:
4747
supplier_invoice.write({"ref": self.name})
4848

49-
def action_post(self):
49+
def _post(self, soft=True):
5050
"""Validated invoice generate cross invoice base on company rules"""
51-
res = super().action_post()
51+
res = super()._post(soft=soft)
5252
# Intercompany account entries or receipts aren't supported
5353
supported_types = {"out_invoice", "in_invoice", "out_refund", "in_refund"}
5454
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
@@ -542,6 +542,31 @@ def _confirm_invoice_with_product(self):
542542
self.assertEqual(len(invoices), 1)
543543
return invoices
544544

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

0 commit comments

Comments
 (0)