[FIX] account: payment state reversed payment move
Steps:
- Create a Customer Invoice CI
- Register a full payment P
- Create a Bank Transaction BT
- Reconcile BT with P
- Go to the payment's move and click on "Reverse Entry" button
-> First issue: Two buttons ("Reverse" and "Reverse and create invoice")
It should be only one ("Reverse")
- Click on "Reverse" button
-> The invoice is still marked as "paid", it should be "not paid"
The reason is that `is_cancel_needed` variable is not well computed
in `reverse_moves()` as since 4d3ac4cbd8,
there is no `refund_method` on the reversal wizard, which was used
instead of `is_modify` parameter, which is not enough in our case.
opw-3772117
closes odoo/odoo#161534
X-original-commit: 5f3c1957b391e3395dbebac4ccb6592af9e4a7dd
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Guillaume Vanleynseele (guva) <guva@odoo.com>
This commit is contained in:
@@ -2407,8 +2407,8 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon):
|
||||
Command.update(line.id, {'balance': amount}),
|
||||
],
|
||||
})
|
||||
|
||||
reverse_move.action_post()
|
||||
if reverse_move.state == 'draft':
|
||||
reverse_move.action_post()
|
||||
|
||||
def create_statement_line(move, amount):
|
||||
statement_line = self.env['account.bank.statement.line'].create({
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import Command
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
from odoo.tests import tagged, new_test_user
|
||||
from odoo.tests.common import Form
|
||||
@@ -859,6 +860,30 @@ class TestAccountPayment(AccountTestInvoicingCommon):
|
||||
'is_matched': True,
|
||||
}])
|
||||
|
||||
def test_reconciliation_payment_states_reverse_payment_move(self):
|
||||
invoice = self.env['account.move'].create({
|
||||
'move_type': 'out_invoice',
|
||||
'partner_id': self.partner_a.id,
|
||||
'invoice_line_ids': [Command.create({'product_id': self.product_a.id})],
|
||||
})
|
||||
invoice.action_post()
|
||||
|
||||
payment = self.env['account.payment.register']\
|
||||
.with_context(active_model='account.move', active_ids=invoice.ids)\
|
||||
.create({})\
|
||||
._create_payments()
|
||||
|
||||
self.assertTrue(invoice.payment_state in ('paid', 'in_payment'))
|
||||
self.assertRecordValues(payment, [{'reconciled_invoice_ids': invoice.ids}])
|
||||
|
||||
# Reverse the payment move
|
||||
reversal_wizard = self.env['account.move.reversal']\
|
||||
.with_context(active_model='account.move', active_ids=payment.move_id.ids)\
|
||||
.create({'reason': "oopsie", 'journal_id': payment.journal_id.id})
|
||||
reversal_wizard.refund_moves()
|
||||
self.assertRecordValues(invoice, [{'payment_state': 'not_paid'}])
|
||||
self.assertRecordValues(payment.line_ids, [{'reconciled': True}] * 2)
|
||||
|
||||
def test_payment_name(self):
|
||||
AccountPayment = self.env['account.payment']
|
||||
AccountPayment.search([]).unlink()
|
||||
|
||||
@@ -118,7 +118,7 @@ class AccountMoveReversal(models.TransientModel):
|
||||
]
|
||||
for move, default_vals in zip(moves, default_values_list):
|
||||
is_auto_post = default_vals.get('auto_post') != 'no'
|
||||
is_cancel_needed = not is_auto_post and is_modify
|
||||
is_cancel_needed = not is_auto_post and (is_modify or self.move_type == 'entry')
|
||||
batch_index = 0 if is_cancel_needed else 1
|
||||
batches[batch_index][0] |= move
|
||||
batches[batch_index][1].append(default_vals)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</group>
|
||||
<footer>
|
||||
<button string='Reverse' name="refund_moves" type="object" class="btn-primary" data-hotkey="q"/>
|
||||
<button string="Reverse and Create Invoice" name="modify_moves" type="object" class="btn-secondary"/>
|
||||
<button string="Reverse and Create Invoice" name="modify_moves" type="object" class="btn-secondary" invisible="move_type == 'entry'"/>
|
||||
<button string="Discard" class="btn-secondary" special="cancel" data-hotkey="x"/>
|
||||
</footer>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user