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 = {