From e0cebcd65b2452a6eefb39ea1981f41df2cf8da9 Mon Sep 17 00:00:00 2001 From: pinky <> Date: Wed, 7 Mar 2007 18:38:59 +0000 Subject: [PATCH] Contracts availabilities bzr revid: pinky-6503b9a510b0659f7192e7b4d9ae30a2a4b3785e --- addons/hr_contract/hr_contract.py | 1 + addons/hr_contract/hr_contract_view.xml | 4 +- addons/hr_contract_available/__init__.py | 31 ++++++++++ addons/hr_contract_available/__terp__.py | 14 +++++ .../hr_contract_available.py | 59 +++++++++++++++++++ .../hr_contract_available_view.xml | 56 ++++++++++++++++++ 6 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 addons/hr_contract_available/__init__.py create mode 100644 addons/hr_contract_available/__terp__.py create mode 100644 addons/hr_contract_available/hr_contract_available.py create mode 100644 addons/hr_contract_available/hr_contract_available_view.xml diff --git a/addons/hr_contract/hr_contract.py b/addons/hr_contract/hr_contract.py index b913d4142d2..8f97e65f1ca 100644 --- a/addons/hr_contract/hr_contract.py +++ b/addons/hr_contract/hr_contract.py @@ -62,6 +62,7 @@ class hr_contract(osv.osv): 'working_hours_per_day' : fields.integer('Working hours per day'), 'wage_type_id' : fields.many2one('hr.contract.wage.type', 'Wage Type', required=True), 'wage' : fields.float('Wage', required=True), + 'notes' : fields.text('Notes'), } _defaults = { 'date_start' : lambda *a : DateTime.now().strftime("%Y-%m-%d"), diff --git a/addons/hr_contract/hr_contract_view.xml b/addons/hr_contract/hr_contract_view.xml index 21bd0b90893..52f012697c3 100644 --- a/addons/hr_contract/hr_contract_view.xml +++ b/addons/hr_contract/hr_contract_view.xml @@ -54,7 +54,7 @@ - + @@ -85,7 +85,7 @@ - + diff --git a/addons/hr_contract_available/__init__.py b/addons/hr_contract_available/__init__.py new file mode 100644 index 00000000000..a77d4a680b8 --- /dev/null +++ b/addons/hr_contract_available/__init__.py @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Copyright (c) 2004-2006 TINY SPRL. (http://tiny.be) All Rights Reserved. +# +# $Id: account.py 1005 2005-07-25 08:41:42Z nicoe $ +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsability of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# garantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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 +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################## + +import hr_contract_available diff --git a/addons/hr_contract_available/__terp__.py b/addons/hr_contract_available/__terp__.py new file mode 100644 index 00000000000..c5d1eeba90e --- /dev/null +++ b/addons/hr_contract_available/__terp__.py @@ -0,0 +1,14 @@ +{ + "name" : "Human Resources Contracts", + "version" : "0.1", + "author" : "Tiny", + "category" : "Generic Modules/Human Resources", + "website" : "http://tinyerp.com/module_hr.html", + "depends" : ["hr_contract"], + "module": "", + "init_xml" : [], + "demo_xml" : [], + "update_xml" : ["hr_contract_available_view.xml"], + "active": False, + "installable": True +} diff --git a/addons/hr_contract_available/hr_contract_available.py b/addons/hr_contract_available/hr_contract_available.py new file mode 100644 index 00000000000..c875dae2c3b --- /dev/null +++ b/addons/hr_contract_available/hr_contract_available.py @@ -0,0 +1,59 @@ +from osv import fields, osv + +class hr_employee(osv.osv): + _inherit = "hr.employee" + def _get_state(self, cr, uid, ids, name, args, context): + result = {} + for emp in self.browse(cr, uid, ids, context): + result[emp.id] = 'no' + for alloc in emp.allocation_ids: + if ((not alloc.date_end) or (alloc.date_end>='%Y-%m-%d')) and (alloc.date_start<='%Y-%m-%d'): + result[emp.id] = alloc.state + return result + def _get_date_end(self, cr, uid, ids, name, args, context): + result = {} + for emp in self.browse(cr, uid, ids, context): + result[emp.id] = False + if len( emp.allocation_ids): + result[emp.id] = emp.allocation_ids[-1].date_end or False + return result + def _get_department_id(self, cr, uid, ids, name, args, context): + result = {} + for emp in self.browse(cr, uid, ids, context): + result[emp.id] = time.strftime('%Y-%m-%d') + for alloc in emp.allocation_ids: + if ((not alloc.date_end) or (alloc.date_end>='%Y-%m-%d')) and (alloc.date_start<='%Y-%m-%d'): + result[emp.id] = alloc.department_id.id + return result + _columns = { + 'allocation_ids' : fields.one2many('hr.allocation', 'employee_id', 'Allocations'), + 'allocation_state': fields.function(_get_state, + method=True, + type='selection', + selection=[('no','/'),('unavailable','Unavailable'),('ondemand','On demand'),('available','Available')], + string='Current Availability'), + 'allocation_department_id': fields.function(_get_department_id, method=True, type='many2one', relation='res.company', string='Current Department'), + 'allocation_date_end': fields.function(_get_date_end, method=True, type='date', string='Availability Date') + } +hr_employee() + +class hr_allocation(osv.osv): + _name = 'hr.allocation' + _description = 'Allocations' + _columns = { + 'name' : fields.char('Contract Name', size=30, required=True), + 'employee_id' : fields.many2one('hr.employee', 'Employee', required=True, relate=True), + 'department_id' : fields.many2one('res.company', 'Department', required=True, relate=True), + 'function' : fields.many2one('res.partner.function', 'Function'), + 'date_start' : fields.date('Start Date', required=True), + 'date_end' : fields.date('End Date', help="Keep empty for unlimited allocation."), + 'state' : fields.selection([('unavailable','Unavailable'),('ondemand','On demand'),('available','Available')], 'State', required=True), + } + _order = 'date_start' + _defaults = { + 'date_start' : lambda *a : DateTime.now().strftime("%Y-%m-%d"), + 'state' : lambda *a : 'ondemand', + 'department_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id + } +hr_contract() + diff --git a/addons/hr_contract_available/hr_contract_available_view.xml b/addons/hr_contract_available/hr_contract_available_view.xml new file mode 100644 index 00000000000..3e05b7118c3 --- /dev/null +++ b/addons/hr_contract_available/hr_contract_available_view.xml @@ -0,0 +1,56 @@ + + + + + hr.hr.employee.view.form2 + hr.employee + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+
+
+ + + hr.employee.available.tree + hr.employee + tree + hr.view_employee_list + + + + + + + + + +
+
+ +