[FIX] account: payment reconciliation line order

Create 3 invoices for customer (A: $100, B: $300, C: $200)
Have a customer payment of $500
Reconcile the payment, in the widget add the line in the order:
- Payment line
- Invoice A
- Invoice B
- Invoice C (partial payment)
Reconcile
Check invoices

Issue:
C will be fully paid, the partial payment will be applied to B
After 5b2c1d243c0dd5b049ceae280dd270fc8a59f955
We order the lines by amount currency but the user provided order is
lost. Moving the original fix to point of sale

opw-3240586

closes odoo/odoo#120779

X-original-commit: 89f9028901a8b43aab605c12e3c7bcc2a7dd8d44
Related: odoo/enterprise#40805
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Grazioso Andrea (agr) <agr@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2023-05-09 06:07:33 +02:00
parent 8f399a270c
commit c2182ae4d0
+12 -6
View File
@@ -1959,12 +1959,18 @@ class AccountMoveLine(models.Model):
"""
def process_amls(amls):
sorted_amls = amls.sorted(key=lambda aml: (
aml.date_maturity or aml.date,
aml.currency_id,
aml.amount_currency,
aml.balance,
))
if self._context.get('reduced_line_sorting'):
sorted_amls = amls.sorted(key=lambda aml: (
aml.date_maturity or aml.date,
aml.currency_id,
))
else:
sorted_amls = amls.sorted(key=lambda aml: (
aml.date_maturity or aml.date,
aml.currency_id,
aml.amount_currency,
aml.balance,
))
currencies = sorted_amls.currency_id
results = {