diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 0ec2ddb3eae..95355d7c303 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -35,8 +35,6 @@ class hr_employee_category(osv.osv): } def _check_recursion(self, cr, uid, ids, context=None): - if context is None: - context = {} level = 100 while len(ids): cr.execute('select distinct parent_id from hr_employee_category where id IN %s', (tuple(ids), )) @@ -65,8 +63,6 @@ hr_employee_marital_status() class hr_job(osv.osv): def _no_of_employee(self, cr, uid, ids, name, args, context=None): - if context is None: - context = {} res = {} for emp in self.browse(cr, uid, ids): res[emp.id] = len(emp.employee_ids or []) @@ -136,8 +132,6 @@ class hr_employee(osv.osv): } def _get_photo(self, cr, uid, context=None): - if context is None: - context = {} return open(os.path.join( tools.config['addons_path'], 'hr/image', 'photo.png'), 'rb') .read().encode('base64') @@ -157,8 +151,15 @@ class hr_employee(osv.osv): level -= 1 return True + def _check_department_id(self, cr, uid, ids, context=None): + for emp in self.browse(cr, uid, ids, context=context): + if emp.department_id.manager_id and emp.id == emp.department_id.manager_id.id: + return False + return True + _constraints = [ - (_check_recursion, 'Error ! You cannot create recursive Hierarchy of Employees.', ['parent_id']) + (_check_recursion, 'Error ! You cannot create recursive Hierarchy of Employees.', ['parent_id']), + (_check_department_id, 'Error ! You cannot select a department for which the employee is the manager.', ['department_id']), ] hr_employee() @@ -168,9 +169,7 @@ class hr_department(osv.osv): _inherit = 'hr.department' _columns = { 'manager_id': fields.many2one('hr.employee', 'Manager'), -# 'member_ids': fields.many2many('hr.employee', 'hr_department_user_rel', 'department_id', 'user_id', 'Members'), 'member_ids': fields.one2many('hr.employee', 'department_id', 'Members'), -# finding problem to implement one2many field as "hr_departmen_user_rel" is used in another module query } hr_department() diff --git a/addons/hr/hr_department_demo.xml b/addons/hr/hr_department_demo.xml index 082aa010e76..433e77a6dd4 100644 --- a/addons/hr/hr_department_demo.xml +++ b/addons/hr/hr_department_demo.xml @@ -19,41 +19,37 @@ Technical department - + IT - Marketing - + Sales - Sales Europe - Sales America - @@ -110,7 +106,7 @@ - + diff --git a/addons/hr_holidays/test/test_hr_holiday.yml b/addons/hr_holidays/test/test_hr_holiday.yml index 720ca5e9e84..6a124be59c2 100644 --- a/addons/hr_holidays/test/test_hr_holiday.yml +++ b/addons/hr_holidays/test/test_hr_holiday.yml @@ -1,7 +1,7 @@ - In order to test the hr_holiday module in OpenERP, I will Allocate leaves for Employee and manage leaves and leaves requests. - - I create new user "user1" to who makes leave request. + I create new user "user1" who will make leave request. - !record {model: res.users, id: res_users_user0}: company_id: base.main_company diff --git a/addons/hr_recruitment/hr_recruitment_view.xml b/addons/hr_recruitment/hr_recruitment_view.xml index 5056a0c741e..1a38b8d5a5b 100644 --- a/addons/hr_recruitment/hr_recruitment_view.xml +++ b/addons/hr_recruitment/hr_recruitment_view.xml @@ -96,8 +96,8 @@