diff options
| author | Laurent Smet <las@odoo.com> | 2018-10-02 11:16:00 +0200 |
|---|---|---|
| committer | Laurent Smet <las@odoo.com> | 2018-10-02 13:02:35 +0200 |
| commit | 16469ec95be444eda2ace032a938e4bc9d960236 (patch) | |
| tree | 2ee3a274c12e881f1bd0bbe927da368d6325e6a5 | |
| parent | cdf201a1dcef94d9eae706a487fa91645d50d11b (diff) | |
[IMP] account: sort st lines using search instead of sorted
browse doesn't sort using the table _order so we need to sort the lines after that.
This commit improves such sorting by searching insteaf of browsing: it's more elegant.
| -rw-r--r-- | addons/account/models/account_reconcile_model.py | 3 | ||||
| -rw-r--r-- | addons/account/models/reconciliation_widget.py | 6 |
2 files changed, 4 insertions, 5 deletions
diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index 386595e26e8..a98a007a095 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -597,8 +597,7 @@ class AccountReconcileModel(models.Model): reconciled_amls_ids = set() # Iterate all and create results. - sorted_st_lines = sorted(st_lines, key=lambda line: (line.statement_id.id, line.date, -line.sequence, line.id), reverse=True) - for line in sorted_st_lines: + for line in st_lines: line_currency = line.currency_id or line.journal_id.currency_id or line.company_id.currency_id line_residual = line.currency_id and line.amount_currency or line.amount diff --git a/addons/account/models/reconciliation_widget.py b/addons/account/models/reconciliation_widget.py index e9333b5b086..934272c1c81 100644 --- a/addons/account/models/reconciliation_widget.py +++ b/addons/account/models/reconciliation_widget.py @@ -115,8 +115,8 @@ class AccountReconciliation(models.AbstractModel): """ excluded_ids = excluded_ids or [] - bank_statement_lines = self.env['account.bank.statement.line'].browse(st_line_ids) - sorted_st_lines = sorted(bank_statement_lines, key=lambda line: (line.statement_id.id, line.date, -line.sequence, line.id), reverse=True) + # Make a search to preserve the table's order. + bank_statement_lines = self.env['account.bank.statement.line'].search([('id', 'in', st_line_ids)]) reconcile_model = self.env['account.reconcile.model'].search([('rule_type', '!=', 'writeoff_button')]) # Search for missing partners when opening the reconciliation widget. @@ -133,7 +133,7 @@ class AccountReconciliation(models.AbstractModel): # Iterate on st_lines to keep the same order in the results list. bank_statements_left = self.env['account.bank.statement'] - for line in sorted_st_lines: + for line in bank_statement_lines: if matching_amls[line.id].get('status') == 'reconciled': reconciled_move_lines = matching_amls[line.id].get('reconciled_lines') results['value_min'] += 1 |
