From 9e624671d2fea68d6693a1276cad8ce716389320 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 22 Mar 2016 17:06:53 +0100 Subject: [PATCH] [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 --- addons/account/account_bank_statement.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 8ed9c1c41ef..849326d1068 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -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']