From c179005fc74c169bf6bb351021322e06188b62da Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Sat, 3 Jul 2010 15:51:52 +0530 Subject: [PATCH] [IMP] Clean hr_* module (Still need to done) bzr revid: mra@mra-laptop-20100703102152-4ulrrzbkorpd7xei --- addons/hr/__openerp__.py | 19 +- addons/hr/hr.py | 42 ++-- addons/hr/hr_data.xml | 2 + addons/hr/hr_department.py | 40 ++-- addons/hr/hr_installer.xml | 42 ++-- addons/hr/hr_view.xml | 185 +++++++----------- addons/hr/installer.py | 15 +- addons/hr/security/hr_security.xml | 3 + addons/hr_attendance/__openerp__.py | 3 +- addons/hr_attendance/hr_attendance.py | 37 ++-- addons/hr_attendance/hr_attendance_demo.xml | 20 ++ addons/hr_attendance/hr_attendance_report.xml | 2 + addons/hr_attendance/hr_attendance_view.xml | 30 +-- addons/hr_attendance/hr_attendance_wizard.xml | 4 +- .../hr_attendance/report/attendance_errors.py | 9 +- addons/hr_attendance/report/bymonth.py | 10 +- addons/hr_attendance/report/timesheet.py | 9 +- addons/hr_attendance/security/hr_security.xml | 12 +- .../wizard/hr_attendance_bymonth.py | 12 +- .../wizard/hr_attendance_bymonth_view.xml | 8 +- .../wizard/hr_attendance_byweek.py | 10 +- .../wizard/hr_attendance_byweek_view.xml | 10 +- .../wizard/hr_attendance_error.py | 13 +- .../wizard/hr_attendance_error_view.xml | 14 +- .../wizard/hr_attendance_sign_in_out.py | 15 +- .../wizard/hr_attendance_sign_in_out_view.xml | 22 +-- addons/hr_contract/__openerp__.py | 3 +- addons/hr_contract/hr_contract.py | 29 +-- addons/hr_contract/hr_contract_data.xml | 1 + addons/hr_contract/hr_contract_view.xml | 77 ++++---- .../security/hr_contract_security.xml | 10 +- addons/hr_evaluation/__openerp__.py | 40 ++-- addons/hr_evaluation/hr_evaluation.py | 77 ++++---- addons/hr_evaluation/hr_evaluation_demo.xml | 122 ++++++++++-- addons/hr_evaluation/hr_evaluation_view.xml | 84 +++----- addons/hr_evaluation/report/__init__.py | 3 +- .../report/hr_evaluation_report.py | 8 +- .../report/hr_evaluation_report_view.xml | 48 ++--- addons/hr_evaluation/wizard/__init__.py | 1 - .../wizard/hr_evaluation_mail.py | 4 +- .../wizard/hr_evaluation_mail_view.xml | 54 ++--- addons/hr_expense/__openerp__.py | 9 +- addons/hr_expense/board_hr_expense_view.xml | 2 + addons/hr_expense/hr_expense.py | 31 ++- addons/hr_expense/hr_expense_demo.xml | 24 ++- addons/hr_expense/hr_expense_report.xml | 2 + addons/hr_expense/hr_expense_sequence.xml | 3 + addons/hr_expense/hr_expense_view.xml | 46 ++--- addons/hr_expense/hr_expense_workflow.xml | 15 ++ addons/hr_expense/report/__init__.py | 1 + addons/hr_expense/report/expense.py | 5 +- .../report/hr_expense_report_view.xml | 52 ++--- addons/hr_holidays/__init__.py | 1 + addons/hr_holidays/__openerp__.py | 12 +- addons/hr_holidays/board_hr_holidays_view.xml | 3 +- addons/hr_holidays/hr_bel_holidays_2008.xml | 10 + addons/hr_holidays/hr_holidays.py | 76 ++++--- addons/hr_holidays/hr_holidays_report.xml | 1 + addons/hr_holidays/hr_holidays_view.xml | 66 +++---- addons/hr_holidays/hr_holidays_wizard.xml | 1 + .../hr_holidays/report/available_holidays.py | 22 ++- .../report/available_holidays_view.xml | 37 ++-- .../report/holidays_summary_report.py | 5 +- .../hr_holidays/report/hr_holidays_report.py | 17 +- .../report/hr_holidays_report_view.xml | 44 ++--- .../wizard/hr_holidays_summary_department.py | 7 +- .../wizard/hr_holidays_summary_employees.py | 6 +- 67 files changed, 833 insertions(+), 814 deletions(-) diff --git a/addons/hr/__openerp__.py b/addons/hr/__openerp__.py index d4778237420..29e61ba5599 100755 --- a/addons/hr/__openerp__.py +++ b/addons/hr/__openerp__.py @@ -21,11 +21,11 @@ { - "name" : "Human Resources", - "version" : "1.1", - "author" : "Tiny", - "category" : "Generic Modules/Human Resources", - "website" : "http://www.openerp.com", + "name": "Human Resources", + "version": "1.1", + "author": "Tiny", + "category": "Generic Modules/Human Resources", + "website": "http://www.openerp.com", "description": """ Module for human resource management. You can manage: * Employees and hierarchies : You can define your employee with User and display hierarchies @@ -45,10 +45,11 @@ 'hr_installer.xml', 'hr_data.xml', 'board_hr_view.xml', - ], - 'demo_xml': ['hr_demo.xml', - 'hr_department_demo.xml'], - + ], + 'demo_xml': [ + 'hr_demo.xml', + 'hr_department_demo.xml' + ], 'test': ['test/test_hr.yml'], 'installable': True, 'active': False, diff --git a/addons/hr/hr.py b/addons/hr/hr.py index b5db01ac512..372b5214f6f 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -27,9 +27,8 @@ from tools.translate import _ class hr_employee_category(osv.osv): _name = "hr.employee.category" _description = "Employee Category" - _columns = { - 'name' : fields.char("Category", size=64, required=True), + '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') } @@ -37,7 +36,7 @@ class hr_employee_category(osv.osv): 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 %s',(tuple(ids),)) + cr.execute('select distinct parent_id from hr_employee_category where id IN %s', (tuple(ids), )) ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False @@ -54,13 +53,14 @@ class hr_employee_marital_status(osv.osv): _name = "hr.employee.marital.status" _description = "Employee Marital Status" _columns = { - 'name' : fields.char('Marital Status', size=30, required=True), - 'description' : fields.text('Status Description'), + 'name': fields.char('Marital Status', size=30, required=True), + 'description': fields.text('Status Description'), } hr_employee_marital_status() class hr_job(osv.osv): - def _no_of_employee(self, cr, uid, ids, name,args,context=None): + + def _no_of_employee(self, cr, uid, ids, name, args, context=None): res = {} for emp in self.browse(cr, uid, ids): res[emp.id] = len(emp.employee_ids or []) @@ -70,19 +70,19 @@ class hr_job(osv.osv): _description = "Job Description" _columns = { 'name': fields.char('Job Name', size=128, required=True, select=True), - 'expected_employees':fields.integer('Expected Employees', help='Required number of Employees'), + 'expected_employees': fields.integer('Expected Employees', help='Required number of Employees'), 'no_of_employee': fields.function(_no_of_employee, method=True, string='No of Employees', type='integer', help='Number of Employees selected'), - 'employee_ids':fields.one2many('hr.employee', 'job_id','Employees'), + 'employee_ids': fields.one2many('hr.employee', 'job_id', 'Employees'), 'description': fields.text('Job Description'), - 'requirements':fields.text('Requirements'), - 'department_id':fields.many2one('hr.department','Department'), + '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', required=True), } _defaults = { - 'expected_employees': lambda *a: 1, + 'expected_employees': 1, 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'hr.job', context=c), - 'state': lambda *args: 'open' + 'state': 'open' } hr_job() @@ -90,17 +90,17 @@ hr_job() class hr_employee(osv.osv): _name = "hr.employee" _description = "Employee" - _inherits = {'resource.resource':"resource_id"} + _inherits = {'resource.resource': "resource_id"} _columns = { - 'country_id' : fields.many2one('res.country', 'Nationality'), - 'birthday' : fields.date("Birthday"), + 'country_id': fields.many2one('res.country', 'Nationality'), + 'birthday': fields.date("Birthday"), 'ssnid': fields.char('SSN No', size=32, help='Social Security Number'), 'sinid': fields.char('SIN No', size=32), 'otherid': fields.char('Other ID', size=32), - 'gender': fields.selection([('male','Male'),('female','Female')], 'Gender'), + 'gender': fields.selection([('male', 'Male'),('female', 'Female')], 'Gender'), 'marital': fields.many2one('hr.employee.marital.status', 'Marital Status'), 'bank_account': fields.char('Bank Account', size=56), - 'partner_id' : fields.related('company_id', 'partner_id', type='many2one', relation='res.partner', readonly=True), + 'partner_id': fields.related('company_id', 'partner_id', type='many2one', relation='res.partner', readonly=True), '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'), @@ -109,8 +109,8 @@ 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'), - 'child_ids': fields.one2many('hr.employee', 'parent_id','Subordinates'), + 'category_id': fields.many2one('hr.employee.category', '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'), 'job_id': fields.many2one('hr.job', 'Job'), @@ -123,7 +123,7 @@ class hr_employee(osv.osv): 'rb') .read().encode('base64') _defaults = { - 'active' : 1, + 'active': 1, 'photo': _get_photo, } diff --git a/addons/hr/hr_data.xml b/addons/hr/hr_data.xml index 7125afb17d4..f76d1457aa1 100644 --- a/addons/hr/hr_data.xml +++ b/addons/hr/hr_data.xml @@ -1,6 +1,7 @@ + Single @@ -14,5 +15,6 @@ Widower + diff --git a/addons/hr/hr_department.py b/addons/hr/hr_department.py index 9e190a2b0f7..d1e13e2f6ec 100644 --- a/addons/hr/hr_department.py +++ b/addons/hr/hr_department.py @@ -25,6 +25,8 @@ import tools class hr_department(osv.osv): def name_get(self, cr, uid, ids, context=None): + if context is None: + context = {} if not len(ids): return [] reads = self.read(cr, uid, ids, ['name','parent_id'], context) @@ -36,7 +38,7 @@ class hr_department(osv.osv): res.append((record['id'], name)) return res - def _dept_name_get_fnc(self, cr, uid, ids, prop, unknow_none, context): + def _dept_name_get_fnc(self, cr, uid, ids, prop, unknow_none, context=None): res = self.name_get(cr, uid, ids, context) return dict(res) @@ -51,13 +53,19 @@ class hr_department(osv.osv): 'manager_id': fields.many2one('res.users', 'Manager', required=True), 'member_ids': fields.many2many('res.users', 'hr_department_user_rel', 'department_id', 'user_id', 'Members'), } - def _get_members(self,cr, uid, context={}): - mids = self.search(cr, uid, [('manager_id','=',uid)]) + + _defaults = { + 'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'hr.department', context=c), + } + + def _get_members(self,cr, uid, context=None): + mids = self.search(cr, uid, [('manager_id', '=', uid)]) result = {uid:1} for m in self.browse(cr, uid, mids, context): for user in m.member_ids: result[user.id] = 1 return result.keys() + def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): @@ -78,18 +86,17 @@ hr_department() class ir_action_window(osv.osv): _inherit = 'ir.actions.act_window' - def read(self, cr, uid, ids, fields=None, context=None, - load='_classic_read'): + def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'): + if context is None: + context = {} select = ids if isinstance(ids, (int, long)): select = [ids] - res = super(ir_action_window, self).read(cr, uid, select, fields=fields, - context=context, load=load) + res = super(ir_action_window, self).read(cr, uid, select, fields=fields, context=context, load=load) for r in res: mystring = 'department_users_get()' if mystring in (r.get('domain', '[]') or ''): - r['domain'] = r['domain'].replace(mystring, str( - self.pool.get('hr.department')._get_members(cr, uid))) + r['domain'] = r['domain'].replace(mystring, str(self.pool.get('hr.department')._get_members(cr, uid))) if isinstance(ids, (int, long)): if res: return res[0] @@ -103,7 +110,7 @@ class res_users(osv.osv): _inherit = 'res.users' _description = 'User' - def _parent_compute(self, cr, uid, ids, name, args, context={}): + def _parent_compute(self, cr, uid, ids, name, args, context=None): result = {} obj_dept = self.pool.get('hr.department') for user_id in ids: @@ -125,10 +132,12 @@ class res_users(osv.osv): return [('id', 'in', [0])] return [('id', 'in', child_ids.get(uid,[]))] - def _child_compute(self, cr, uid, ids, name, args, context={}): + def _child_compute(self, cr, uid, ids, name, args, context=None): obj_dept = self.pool.get('hr.department') obj_user = self.pool.get('res.users') result = {} + if context is None: + context = {} for manager_id in ids: child_ids = [] mgnt_dept_ids = obj_dept.search(cr, uid, [('manager_id', '=', manager_id)]) @@ -137,10 +146,9 @@ class res_users(osv.osv): data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids']) 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, []) @@ -150,7 +158,7 @@ class res_users(osv.osv): result[manager_id] = child_ids return result - def _child_search(self, cr, uid, obj, name, args, context): + def _child_search(self, cr, uid, obj, name, args, context=None): parent = [] for arg in args: if arg[0] == 'child_ids': @@ -161,9 +169,11 @@ class res_users(osv.osv): return [('id', 'in', child_ids.get(uid,[]))] _columns = { - 'parent_id': fields.function(_parent_compute, relation='res.users',fnct_search=_parent_search, method=True, string="Managers", type='many2many'), + 'parent_id': fields.function(_parent_compute, relation='res.users', fnct_search=_parent_search, method=True, string="Managers", type='many2many'), 'child_ids': fields.function(_child_compute, relation='res.users', fnct_search=_child_search, method=True, string="Subordinates", type='many2many'), 'context_department_id': fields.many2one('hr.department', 'Departments'), } + res_users() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr/hr_installer.xml b/addons/hr/hr_installer.xml index 6859150e855..c0d388517eb 100644 --- a/addons/hr/hr_installer.xml +++ b/addons/hr/hr_installer.xml @@ -1,5 +1,7 @@ + + hr.installer.view hr.installer @@ -7,20 +9,18 @@ -
- Select Human Resources Modules To Install -
- - - Select Human Resources Modules To Install - - +
+ Select Human Resources Modules To Install +
+ + Select Human Resources Modules To Install + + - - - The base Human Resources addon will help you manage your employee roster, but you can enhance it even further by installing a few HR-related applications. - +
+ + The base Human Resources addon will help you manage your employee roster, but you can enhance it even further by installing a few HR-related applications. + @@ -51,16 +51,18 @@ 3
- - ir.actions.todo - hr_installer_action_replace - tree - - + + + ir.actions.todo + hr_installer_action_replace + tree + +