Merge pull request #226 from akretion/8.0-fix-trial_balance_accounts_order-v2

8.0 account_financial_report_webkit: FIX the order of accounts in trial balance
pull/245/head
Pedro M. Baeza 2016-09-20 19:30:25 +02:00 committed by GitHub
commit ec51cd2f19
1 changed files with 6 additions and 1 deletions

View File

@ -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)