[FIX] account: bank statement lines order on write

When adding new lines to an existing statement,
the order of the lines was not kept,
due to the re-sequencing operation done in the
override of `write` in `account.bank.statement`:

```
for statement in self.browse(cr, uid, ids, context):
    for idx, line in enumerate(statement.line_ids):
        account_bank_statement_line_obj.write(cr, uid, [line.id], {'sequence': idx + 1}, context=context)
```
as the lines order was based on `statement_id desc, sequence`,
which is the same for all lines added,
(except if the order is forced in the web client,
using the handle widget)
and, therefore, the order
of the lines returned by `statement.line_ids` was
not determinist.

Adding the `id` to the lines order
(as it's done in `sale.order`, for instance),
solves the issue, as the lines will then be fetched
in the order they were created.

opw-667541
This commit is contained in:
Denis Ledoux 2016-03-22 17:06:53 +01:00
parent e94be1856c
commit 9e624671d2
1 changed files with 1 additions and 1 deletions

View File

@ -924,7 +924,7 @@ class account_bank_statement_line(osv.osv):
user = self.pool.get("res.users").browse(cr, uid, uid)
return ['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id]), ('journal_entry_id', '=', False), ('account_id', '=', False)]
_order = "statement_id desc, sequence"
_order = "statement_id desc, sequence, id"
_name = "account.bank.statement.line"
_description = "Bank Statement Line"
_inherit = ['ir.needaction_mixin']