# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
class hr_employee_category(osv.osv):
_name = "hr.employee.category"
_description = "Employee Category"
-
+
_columns = {
'name' : fields.char("Category", size=64, required=True),
'parent_id': fields.many2one('hr.employee.category', 'Parent Category', select=True),
'child_ids': fields.one2many('hr.employee.category', 'parent_id', 'Child Categories')
}
-
+
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
- cr.execute('select distinct parent_id from hr_employee_category where id in ('+','.join(map(str, ids))+')')
+ cr.execute('select distinct parent_id from hr_employee_category where id=ANY(%s)',(ids,))
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
level -= 1
return True
-
+
_constraints = [
(_check_recursion, 'Error ! You cannot create recursive Categories.', ['parent_id'])
]
-
+
hr_employee_category()
class hr_employee(osv.osv):
_defaults = {
'active' : lambda *a: True,
}
-
+
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
- cr.execute('select distinct parent_id from hr_employee where id in ('+','.join(map(str, ids))+')')
+ cr.execute('select distinct parent_id from hr_employee where id =ANY(%s)',(ids,))
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
level -= 1
return True
-
+
_constraints = [
(_check_recursion, 'Error ! You cannot create recursive Hierarchy of Employees.', ['parent_id'])
]
-
+
hr_employee()
class hr_timesheet(osv.osv):
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
def _check_recursion(self, cr, uid, ids):
level = 100
while len(ids):
- cr.execute('select distinct parent_id from hr_department where id in ('+','.join(map(str, ids))+')')
+ cr.execute('select distinct parent_id from hr_department where id =ANY(%s)',(ids,))
ids = filter(None, map(lambda x:x[0], cr.fetchall()))
if not level:
return False
ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)])
if ids_dept:
data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'])
- childs = map(lambda x: x['member_ids'], data_dept)
+ childs = map(lambda x: x['member_ids'], data_dept)
childs = tools.flatten(childs)
- childs = obj_user.search(cr, uid, [('id','in',childs),('active','=',True)])
+ childs = obj_user.search(cr, uid, [('id','in',childs),('active','=',True)])
if manager_id in childs:
childs.remove(manager_id)
-
+
child_ids.extend(tools.flatten(childs))
set = {}
map(set.__setitem__, child_ids, [])