diff --git a/addons/hr/__openerp__.py b/addons/hr/__openerp__.py index 29e61ba5599..443848fbff4 100755 --- a/addons/hr/__openerp__.py +++ b/addons/hr/__openerp__.py @@ -48,9 +48,9 @@ ], 'demo_xml': [ 'hr_demo.xml', - 'hr_department_demo.xml' - ], - 'test': ['test/test_hr.yml'], + 'hr_department_demo.xml', + ], + 'test': ['test/test_hr.yml'], 'installable': True, 'active': False, 'certificate': '0086710558965', diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 41aecc0bce0..ab7d6189621 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -78,7 +78,7 @@ class hr_job(osv.osv): 'requirements': fields.text('Requirements'), 'department_id': fields.many2one('hr.department', 'Department'), 'company_id': fields.many2one('res.company', 'Company'), - 'state': fields.selection([('open', 'Open'),('old', 'Old'),('recruit', 'In Recruitement')], 'State', required=True), + 'state': fields.selection([('open', 'Open'),('old', 'Old'),('recruit', 'In Recruitement')], 'State', readonly=True, required=True), } _defaults = { 'expected_employees': 1, @@ -86,6 +86,18 @@ class hr_job(osv.osv): 'state': 'open' } + def job_old(self, cr, uid, ids, *args): + self.write(cr, uid, ids, {'state': 'old'}) + return True + + def job_recruitement(self, cr, uid, ids, *args): + self.write(cr, uid, ids, {'state': 'recruit'}) + return True + + def job_open(self, cr, uid, ids, *args): + self.write(cr, uid, ids, {'state': 'open'}) + return True + hr_job() class hr_employee(osv.osv): @@ -102,7 +114,7 @@ class hr_employee(osv.osv): 'marital': fields.many2one('hr.employee.marital.status', 'Marital Status'), 'bank_account': fields.char('Bank Account', size=64), 'partner_id': fields.related('company_id', 'partner_id', type='many2one', relation='res.partner', readonly=True), - 'department_id':fields.many2one('hr.department','Department'), + 'department_id':fields.many2one('hr.department', 'Department'), 'address_id': fields.many2one('res.partner.address', 'Working Address'), 'address_home_id': fields.many2one('res.partner.address', 'Home Address'), 'work_phone': fields.related('address_id', 'phone', type='char', string='Work Phone', readonly=True), @@ -110,10 +122,12 @@ class hr_employee(osv.osv): 'work_location': fields.char('Office Location', size=32), 'notes': fields.text('Notes'), 'parent_id': fields.many2one('hr.employee', 'Manager', select=True), - 'category_id': fields.many2one('hr.employee.category', 'Category'), +# 'parent_id': fields.related('department_id', 'manager_id', string='Manager', type='many2one'), +# 'category_id': fields.many2one('hr.employee.category', 'Category'), + 'category_ids': fields.many2many('hr.employee.category', 'employee_category_rel','category_id','emp_id','Category'), 'child_ids': fields.one2many('hr.employee', 'parent_id', 'Subordinates'), 'resource_id': fields.many2one('resource.resource', 'Resource', ondelete='cascade'), - 'coach_id': fields.many2one('res.users', 'Coach'), + 'coach_id': fields.many2one('hr.employee', 'Coach'), 'job_id': fields.many2one('hr.job', 'Job'), 'photo': fields.binary('Photo') } @@ -129,6 +143,8 @@ class hr_employee(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 where id IN %s',(tuple(ids),)) @@ -144,4 +160,17 @@ class hr_employee(osv.osv): hr_employee() +class hr_department(osv.osv): + _description = "Department" + _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() + + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/hr/hr_demo.xml b/addons/hr/hr_demo.xml index 572eb3c1060..28be1d987f4 100644 --- a/addons/hr/hr_demo.xml +++ b/addons/hr/hr_demo.xml @@ -4,38 +4,38 @@ - + CEO - + CTO - + - + Managers(Tech. Heads) - + - + Project Managers - + - + Sr. Executives(Team Leads) - + - + Jr. Executives(Developers) - + - + Trainee(Intership) - + @@ -46,9 +46,10 @@ - + + diff --git a/addons/hr/hr_department.py b/addons/hr/hr_department.py index 0a21e8aecee..47c4c0e0fc7 100644 --- a/addons/hr/hr_department.py +++ b/addons/hr/hr_department.py @@ -50,8 +50,8 @@ class hr_department(osv.osv): 'parent_id': fields.many2one('hr.department', 'Parent Department', select=True), 'child_ids': fields.one2many('hr.department', 'parent_id', 'Child Departments'), 'note': fields.text('Note'), - 'manager_id': fields.many2one('res.users', 'Manager', required=True), - 'member_ids': fields.many2many('res.users', 'hr_department_user_rel', 'department_id', 'user_id', 'Members'), +# 'manager_id': fields.many2one('res.users', 'Manager'), +# 'member_ids': fields.many2many('res.users', 'hr_department_user_rel', 'department_id', 'user_id', 'Members'), } _defaults = { diff --git a/addons/hr/hr_department_demo.xml b/addons/hr/hr_department_demo.xml index bc1649bbef5..2fb859a804e 100644 --- a/addons/hr/hr_department_demo.xml +++ b/addons/hr/hr_department_demo.xml @@ -5,57 +5,105 @@ Management - + Administration - + Technical department - + IT - + Marketing - + Sales - + Sales Europe - + Sales America - + + + + + CEO + + + + + CTO + + + + + HR Manager + + + + + Project Managers + + + + + Senior Application Analyst + + + + + Junior Application Analyst + + + + + Senior Developers + + + + + Junior Developers + + + + + Trainee + + + + diff --git a/addons/hr/hr_view.xml b/addons/hr/hr_view.xml index a3f24324ea1..55415ed8088 100644 --- a/addons/hr/hr_view.xml +++ b/addons/hr/hr_view.xml @@ -62,12 +62,14 @@ - + + + @@ -88,7 +90,6 @@ - @@ -341,7 +342,12 @@ - + + +