[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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user