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 #736
  • Loading branch information
metaminux committed Dec 11, 2024
1 parent c5bb14c commit 7c04445
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions account_invoice_inter_company/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def _find_company_from_invoice_partner(self):
)
return company or False

def action_post(self):
def _post(self, soft=True):
"""Validated invoice generate cross invoice base on company rules"""
res = super().action_post()
res = super()._post(soft=soft)
# Intercompany account entries or receipts aren't supported
supported_types = {"out_invoice", "in_invoice", "out_refund", "in_refund"}
for src_invoice in self.filtered(lambda x: x.move_type in supported_types):
Expand Down
25 changes: 25 additions & 0 deletions account_invoice_inter_company/tests/test_inter_company_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,3 +553,28 @@ 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 for 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_ids field
context = {
"active_model": "account.move",
"active_ids": self.invoice_company_a.ids,
}
with Form(
self.env["account.move.reversal"]
.with_context(**context)
.with_user(self.user_company_a.id)
) as wizard_form:
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 7c04445

Please sign in to comment.