Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] account_invoice_inter_company : creating a credit note should g… #738

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -46,9 +46,9 @@ def _set_intercompany_supplier_invoice_ref(self):
if not supplier_invoice.ref:
supplier_invoice.write({"ref": self.name})

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 @@ -542,6 +542,31 @@ def _confirm_invoice_with_product(self):
self.assertEqual(len(invoices), 1)
return 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)])
)

def test_confirm_invoice_intercompany_disabled(self):
# ensure the catalog is shared
self.env.ref("product.product_comp_rule").write({"active": False})
Expand Down