From dc4be54730b8e08c9a64cfd8f76e733853edf1be Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 19 Sep 2016 16:37:20 +0200 Subject: [PATCH] FIX the order of accounts in trial balance when there is a filter on accounts --- account_financial_report_webkit/report/common_reports.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/account_financial_report_webkit/report/common_reports.py b/account_financial_report_webkit/report/common_reports.py index 240148bb..7bbefe3d 100644 --- a/account_financial_report_webkit/report/common_reports.py +++ b/account_financial_report_webkit/report/common_reports.py @@ -28,6 +28,7 @@ from openerp.osv import osv from openerp.tools.translate import _ from openerp.addons.account.report.common_report_header \ import common_report_header +from collections import OrderedDict _logger = logging.getLogger('financial.reports.webkit') @@ -204,7 +205,11 @@ class CommonReportHeaderWebkit(common_report_header): self.cursor, self.uid, domain) else: accounts += children_acc_ids - res_ids = list(set(accounts)) + # remove duplicate account IDs in accounts + # We don't use list(set(accounts)) to keep the order + # cf http://stackoverflow.com/questions/7961363/ + # removing-duplicates-in-lists + res_ids = list(OrderedDict.fromkeys(accounts)) res_ids = self.sort_accounts_with_structure( account_ids, res_ids, context=context)