From c2182ae4d076f02020a459532011e8187e9bf57c Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Mon, 24 Apr 2023 10:23:48 +0000 Subject: [PATCH] [FIX] account: payment reconciliation line order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) Signed-off-by: Grazioso Andrea (agr) --- addons/account/models/account_move_line.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/account/models/account_move_line.py b/addons/account/models/account_move_line.py index 5b256cdbc78..28898b54284 100644 --- a/addons/account/models/account_move_line.py +++ b/addons/account/models/account_move_line.py @@ -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 = {