1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
26 from report import report_sxw
27 from itertools import groupby
28 from operator import itemgetter
29 from tools.translate import _
31 # Use period and Journal for selection or resources
33 class report_assert_account(report_sxw.rml_parse):
34 def __init__(self, cr, uid, name, context):
35 super(report_assert_account, self).__init__(cr, uid, name, context=context)
36 self.localcontext.update( {
39 'execute_code': self.execute_code,
42 def execute_code(self, code_exec):
44 return dict((k, [v for v in itr]) for k, itr in groupby(sorted(lst, key=lambda x: x[col]), itemgetter(col)))
47 reconciled_inv_ids = self.pool.get('account.invoice').search(self.cr, self.uid, [('reconciled','=',True)])
48 return reconciled_inv_ids
50 def get_parent(acc_id):
51 acc_an_id = self.pool.get('account.analytic.account').browse(self.cr, self.uid, acc_id).parent_id
52 while acc_an_id.parent_id:
53 acc_an_id = acc_an_id.parent_id
56 def order_columns(item, cols=None):
59 return [(col, item.get(col)) for col in cols if col in item.keys()]
64 'reconciled_inv' : reconciled_inv,
66 'get_parent' : get_parent,
67 'now': datetime.datetime.now(),
72 exec code_exec in localdict
74 result = localdict['result']
75 column_order = localdict.get('column_order', None)
77 if not isinstance(result, (tuple, list, set)):
80 result = [_('The test was passed successfully')]
83 if isinstance(a, dict):
84 return ', '.join(["%s: %s" % (tup[0], tup[1]) for tup in order_columns(a, column_order)])
87 result = [_format(rec) for rec in result]
91 report_sxw.report_sxw('report.account.test.assert.print', 'accounting.assert.test', 'addons/account_test/report/account_test.rml', parser=report_assert_account, header=False)
93 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: