[FIX] account_payment_order: incorrect inbound partial reconciliations

- Also added float_compare to avoid possible rounding issues
This commit is contained in:
Ethan Hildick
2023-07-25 17:03:16 +02:00
parent 8c3de858ad
commit b7e7383d9a
2 changed files with 14 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import base64
from odoo import _, api, fields, models
from odoo.exceptions import UserError, ValidationError
from odoo.tools import float_compare
class AccountPaymentOrder(models.Model):
@@ -433,7 +434,15 @@ class AccountPaymentOrder(models.Model):
for line in payment.payment_line_ids:
if not line.move_line_id:
continue
if line.amount_currency != -line.move_line_id.amount_residual_currency:
sign = -1 if payment.payment_order_id.payment_type == "outbound" else 1
if (
float_compare(
line.amount_currency,
(line.move_line_id.amount_residual_currency * sign),
precision_rounding=line.move_line_id.currency_id.rounding,
)
!= 0
):
if line.move_line_id.amount_residual_currency < 0:
debit_move_id = payment_move_line_id.id
credit_move_id = line.move_line_id.id

View File

@@ -111,6 +111,10 @@ class TestPaymentOrderInbound(TestPaymentOrderInboundBase):
self.assertEqual(payment_order.state, "uploaded")
with self.assertRaises(UserError):
payment_order.unlink()
matching_number = (
payment_order.payment_ids.payment_line_ids.move_line_id.matching_number
)
self.assertTrue(matching_number and matching_number != "P")
payment_order.action_uploaded_cancel()
self.assertEqual(payment_order.state, "cancel")