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 ##############################################################################
23 from osv import osv, fields
24 from tools.translate import _
26 class account_analytic_profit(osv.osv_memory):
27 _name = 'hr.timesheet.analytic.profit'
28 _description = 'Print Timesheet Profit'
30 'date_from': fields.date('From', required=True),
31 'date_to': fields.date('To', required=True),
32 'journal_ids': fields.many2many('account.analytic.journal', 'analytic_profit_journal_rel', 'analytic_id', 'journal_id', 'Journal', required=True),
33 'employee_ids': fields.many2many('res.users', 'analytic_profit_emp_rel', 'analytic_id', 'emp_id', 'User', required=True),
37 return datetime.datetime.today().strftime('%Y-%m-1')
40 return datetime.datetime.today().strftime('%Y-%m-%d')
43 'date_from': _date_from,
47 def print_report(self, cr, uid, ids, context=None):
48 line_obj = self.pool.get('account.analytic.line')
50 data['form'] = self.read(cr, uid , ids, [], context=context)[0]
51 ids_chk = line_obj.search(cr, uid, [
52 ('date', '>=', data['form']['date_from']),
53 ('date', '<=', data['form']['date_to']),
54 ('journal_id', 'in', data['form']['journal_ids']),
55 ('user_id', 'in', data['form']['employee_ids']),
58 raise osv.except_osv(_('Data Insufficient!'), _('No Records Found for Report!'))
60 data['form']['journal_ids'] = [(6, 0, data['form']['journal_ids'])] # Improve me => Change the rml/sxw so that it can support withou [0][2]
61 data['form']['employee_ids'] = [(6, 0, data['form']['employee_ids'])]
64 'model': 'account.analytic.line',
68 'type': 'ir.actions.report.xml',
69 'report_name': 'account.analytic.profit',
73 account_analytic_profit()
75 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: