Skip to content

Commit

Permalink
[IMP] base_transaction_id: propagate transaction_id to account move r…
Browse files Browse the repository at this point in the history
…eversal
  • Loading branch information
ACheung-FactorLibre committed Aug 29, 2023
1 parent afed064 commit d0aef7f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions base_transaction_id/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import models
from . import wizard
1 change: 1 addition & 0 deletions base_transaction_id/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2019 Camptocamp SA
# Copyright 2022 Simone Rubino - Agile Business Group
# © 2023 FactorLibre - Alejandro Ji Cheung <alejandro.jicheung@factorlibre.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
"name": "Base transaction ID for financial institutes",
Expand Down
20 changes: 20 additions & 0 deletions base_transaction_id/tests/test_transaction_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,25 @@ def test_transaction_propagation(self):
# post-condition: there is an invoice
# and has the same transaction of the sale order
invoice = first(self.sale_order.invoice_ids)
invoice.action_post()
self.assertTrue(invoice)
self.assertEqual(invoice.transaction_id, transaction_id)

# create reversal invoice
account_move_reversal = (
self.env["account.move.reversal"]
.with_context(active_model="account.move", active_ids=invoice.ids)
.create(
{
"journal_id": invoice.journal_id.id,
"reason": "no reason",
"refund_method": "refund",
}
)
)
account_move_reversal.with_context(refund_method="refund").reverse_moves()
self.assertEqual(1, len(invoice.reversal_move_id))
refund = invoice.reversal_move_id

# check if the reversal move has the same transaction of the invoice
self.assertEqual(invoice.transaction_id, refund.transaction_id)
1 change: 1 addition & 0 deletions base_transaction_id/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_move_reversal
11 changes: 11 additions & 0 deletions base_transaction_id/wizard/account_move_reversal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo import fields, models, api


class AccountMoveReversal(models.TransientModel):
_inherit = 'account.move.reversal'

def _prepare_default_reversal(self, move):
res = super()._prepare_default_reversal(move)
if move.transaction_id:
res["transaction_id"] = move.transaction_id
return res

0 comments on commit d0aef7f

Please sign in to comment.