2009-10-13 05:58:37 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2006-12-07 13:41:40 +00:00
|
|
|
##############################################################################
|
2010-04-19 06:42:00 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
2008-11-03 19:18:56 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-10-14 11:15:34 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-04-19 06:42:00 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-12-07 13:41:40 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
import datetime
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
|
|
|
from openerp.tools.translate import _
|
2006-12-07 13:41:40 +00:00
|
|
|
|
2010-04-19 06:42:00 +00:00
|
|
|
class analytical_timesheet_employee(osv.osv_memory):
|
|
|
|
_name = 'hr.analytical.timesheet.employee'
|
2010-04-20 06:11:38 +00:00
|
|
|
_description = 'Print Employee Timesheet & Print My Timesheet'
|
2010-04-19 06:42:00 +00:00
|
|
|
_columns = {
|
2012-10-02 14:19:43 +00:00
|
|
|
'month': fields.selection([(1,'January'), (2,'February'), (3,'March'), (4,'April'),
|
|
|
|
(5,'May'), (6,'June'), (7,'July'), (8,'August'), (9,'September'),
|
|
|
|
(10,'October'), (11,'November'), (12,'December')], 'Month', required=True),
|
2010-04-19 06:42:00 +00:00
|
|
|
'year': fields.integer('Year', required=True),
|
2010-10-08 13:22:47 +00:00
|
|
|
'employee_id': fields.many2one('hr.employee', 'Employee', required=True)
|
2011-02-15 10:39:43 +00:00
|
|
|
|
2010-04-19 06:42:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def _get_user(self, cr, uid, context=None):
|
2010-10-08 13:22:47 +00:00
|
|
|
|
|
|
|
emp_obj = self.pool.get('hr.employee')
|
|
|
|
emp_id = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
|
|
|
|
if not emp_id:
|
2012-07-25 12:13:54 +00:00
|
|
|
raise osv.except_osv(_("Warning!"), _("Please define employee for this user!"))
|
2010-10-08 13:22:47 +00:00
|
|
|
return emp_id and emp_id[0] or False
|
2010-04-19 06:42:00 +00:00
|
|
|
|
|
|
|
_defaults = {
|
2010-11-04 12:42:42 +00:00
|
|
|
'month': lambda *a: datetime.date.today().month,
|
|
|
|
'year': lambda *a: datetime.date.today().year,
|
2010-10-08 13:22:47 +00:00
|
|
|
'employee_id': _get_user
|
2010-04-19 06:42:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def print_report(self, cr, uid, ids, context=None):
|
|
|
|
data = self.read(cr, uid, ids, context=context)[0]
|
2011-03-01 12:48:41 +00:00
|
|
|
data['employee_id'] = data['employee_id'][0]
|
2010-04-19 06:42:00 +00:00
|
|
|
datas = {
|
|
|
|
'ids': [],
|
|
|
|
'model': 'hr.employee',
|
|
|
|
'form': data
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
'type': 'ir.actions.report.xml',
|
|
|
|
'report_name': 'hr.analytical.timesheet',
|
|
|
|
'datas': datas,
|
|
|
|
}
|
2010-07-26 06:15:27 +00:00
|
|
|
|
2010-10-08 13:22:47 +00:00
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|