1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
24 from osv import osv, fields
25 from tools.translate import _
27 class account_crossovered_analytic(osv.osv_memory):
28 _name = "account.crossovered.analytic"
29 _description = "Print Crossovered Analytic"
31 'date1': fields.date('Start Date', required=True),
32 'date2': fields.date('End Date', required=True),
33 'journal_ids': fields.many2many('account.analytic.journal', 'crossovered_journal_rel', 'crossover_id', 'journal_id', 'Analytic Journal'),
34 'ref': fields.many2one('account.analytic.account', 'Analytic Account Reference', required=False),
35 'empty_line': fields.boolean('Dont show empty lines'),
38 'date1': lambda *a: time.strftime('%Y-01-01'),
39 'date2': lambda *a: time.strftime('%Y-%m-%d'),
42 def print_report(self, cr, uid, ids, context=None):
43 cr.execute('SELECT account_id FROM account_analytic_line')
45 acc_ids = [x[0] for x in res]
47 data = self.read(cr, uid, ids, [], context=context)[0]
49 obj_acc = self.pool.get('account.analytic.account').browse(cr, uid, data['ref'], context=context)
52 account_ids = self.pool.get('account.analytic.account').search(cr, uid, [('parent_id', 'child_of', [data['ref']])], context=context)
55 for acc in account_ids:
60 raise osv.except_osv(_('User Error'),_('There are no Analytic lines related to Account %s' % name))
64 'model': 'account.analytic.account',
68 'type': 'ir.actions.report.xml',
69 'report_name': 'account.analytic.account.crossovered.analytic',
73 account_crossovered_analytic()
75 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: