[FIX] moves the field definitions of models hr.job and hr.employee that should have...
authorGery Debongnie <ged@openerp.com>
Tue, 15 Apr 2014 10:54:19 +0000 (12:54 +0200)
committerGery Debongnie <ged@openerp.com>
Tue, 15 Apr 2014 10:54:19 +0000 (12:54 +0200)
bzr revid: ged@openerp.com-20140415105419-wy026n5k10wo80wb

addons/hr/hr.py
addons/hr_contract/hr_contract.py
addons/hr_evaluation/hr_evaluation.py
addons/hr_evaluation/hr_evaluation_view.xml
addons/hr_holidays/hr_holidays.py
addons/hr_payroll/hr_payroll.py
addons/hr_recruitment/hr_recruitment.py
addons/hr_recruitment/hr_recruitment_view.xml
addons/hr_timesheet_sheet/hr_timesheet_sheet.py

index 4efa72e..a13a186 100644 (file)
@@ -92,17 +92,6 @@ class hr_job(osv.Model):
                 res.append(employee.job_id.id)
         return res
 
-    def _count_all(self, cr, uid, ids, field_name, arg, context=None):
-        res = dict(map(lambda x: (x,{'documents_count': 0, 'application_count': 0,}), ids))
-        try:
-            for data in self.browse(cr, uid, ids, context=context):
-                res[data.id] = {'documents_count': len(data.document_ids),
-                'application_count': len(data.applicant_ids),
-                }
-        except:
-            pass
-        return res
-
     _name = "hr.job"
     _description = "Job Position"
     _inherit = ['mail.thread', 'ir.needaction_mixin']
@@ -133,10 +122,6 @@ class hr_job(osv.Model):
                                   track_visibility='always',
                                   help="By default 'Closed', set it to 'In Recruitment' if recruitment process is going on for this job position."),
         'write_date': fields.datetime('Update Date', readonly=True),
-        'applicant_ids':fields.one2many('hr.applicant', 'job_id', 'Applications'),
-        'application_count': fields.function(_count_all, type='integer', string='Applications', multi=True),
-        'document_ids': fields.one2many('ir.attachment', 'company_id', 'Documents'),
-        'documents_count': fields.function(_count_all, type='integer', string='Documents', multi=True),
     }
 
     _defaults = {
@@ -201,20 +186,6 @@ class hr_employee(osv.osv):
 
     def _set_image(self, cr, uid, id, name, value, args, context=None):
         return self.write(cr, uid, [id], {'image': tools.image_resize_image_big(value)}, context=context)
-    
-    def _count_all(self, cr, uid, ids, field_name, arg, context=None):
-        res = dict(map(lambda x: (x,{'appraisal_count': 0, 'leaves_count': 0, 'contracts_count': 0, 'timesheet_count': 0, 'payslip_count': 0,}), ids))
-        try:
-            for datas in self.browse(cr, uid, ids, context=context):
-                res[datas.id] = {'appraisal_count': len(datas.appraisal_ids),
-                'leaves_count': len(datas.leave_ids),
-                'contracts_count': len(datas.contract_ids),
-                'timesheet_count': len(datas.timsheet_ids),
-                'payslip_count': len(datas.payslip_ids)
-                }
-        except:
-            pass
-        return res
 
     _columns = {
         #we need a related field in order to be able to sort the employee by name
@@ -266,16 +237,6 @@ class hr_employee(osv.osv):
         'city': fields.related('address_id', 'city', type='char', string='City'),
         'login': fields.related('user_id', 'login', type='char', string='Login', readonly=1),
         'last_login': fields.related('user_id', 'date', type='datetime', string='Latest Connection', readonly=1),
-        'appraisal_ids': fields.one2many('hr.evaluation.interview', 'user_to_review_id', 'Appraisal Interviews'),
-        'leave_ids': fields.one2many('hr.holidays', 'employee_id', 'Leaves'),
-        'contracts_ids': fields.one2many('hr.contract', 'employee_id', 'Contracts'),
-        'timsheet_ids': fields.one2many('hr_timesheet_sheet.sheet', 'employee_id', 'Timesheets'),
-        'payslip_ids': fields.one2many('hr.payslip', 'employee_id', 'Payslips'),
-        'appraisal_count': fields.function(_count_all, type='integer', string='Appraisal Interviews', multi=True),
-        'leaves_count': fields.function(_count_all, type='integer', string='Leaves', multi=True),
-        'contracts_count': fields.function(_count_all, type='integer', string='Contracts', multi=True),
-        'timesheet_count': fields.function(_count_all, type='integer', string='Timsheets', multi=True),
-        'payslip_count': fields.function(_count_all, type='integer', string='Payslips', multi=True),
     }
 
     def _get_default_image(self, cr, uid, context=None):
index d74253b..d641c49 100644 (file)
@@ -38,6 +38,15 @@ class hr_employee(osv.osv):
                 res[emp.id] = False
         return res
 
+    def _contracts_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,0), ids))
+        try:
+            for employee in self.browse(cr, uid, ids, context=context):
+                res[employee.id] = len(employee.contract_ids)
+        except:
+            pass
+        return res
+
     _columns = {
         'manager': fields.boolean('Is a Manager'),
         'medic_exam': fields.date('Medical Examination Date'),
@@ -47,6 +56,7 @@ class hr_employee(osv.osv):
         'vehicle_distance': fields.integer('Home-Work Dist.', help="In kilometers"),
         'contract_ids': fields.one2many('hr.contract', 'employee_id', 'Contracts'),
         'contract_id':fields.function(_get_latest_contract, string='Contract', type='many2one', relation="hr.contract", help='Latest contract of the employee'),
+        'contracts_count': fields.function(_contracts_count, type='integer', string='Contracts'),
     }
 
 
index 462154e..bfcbf6a 100644 (file)
@@ -102,11 +102,22 @@ class hr_employee(osv.osv):
     _name = "hr.employee"
     _inherit="hr.employee"
     
+    def _appraisal_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,0), ids))
+        try:
+            for employee in self.browse(cr, uid, ids, context=context):
+                res[employee.id] = len(employee.appraisal_ids)
+        except:
+            pass
+        return res
 
     _columns = {
         'evaluation_plan_id': fields.many2one('hr_evaluation.plan', 'Appraisal Plan'),
         'evaluation_date': fields.date('Next Appraisal Date', help="The date of the next appraisal is computed by the appraisal plan's dates (first appraisal + periodicity)."),
+        'appraisal_ids': fields.one2many('hr.evaluation.interview', 'user_to_review_id', 'Appraisal Interviews'),
+        'appraisal_count': fields.function(_appraisal_count, type='integer', string='Appraisal Interviews'),
     }
+
     def run_employee_evaluation(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
         now = parser.parse(datetime.now().strftime('%Y-%m-%d'))
         obj_evaluation = self.pool.get('hr_evaluation.evaluation')
index ab83630..e2b6a62 100644 (file)
                     class="oe_stat_button"
                     icon="fa-sitemap"
                     type="action">
-                    <field name="appraisal_count" widget="statinfo" string="Form"/>
+                    <field name="appraisal_count" widget="statinfo" string="Appraisals"/>
                 </button>
             </xpath>
             </field>
index 932a290..356287d 100644 (file)
@@ -549,6 +549,15 @@ class hr_employee(osv.osv):
             result[holiday.employee_id.id]['current_leave_id'] = holiday.holiday_status_id.id
         return result
 
+    def _leaves_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,0), ids))
+        try:
+            for employee in self.browse(cr, uid, ids, context=context):
+                res[employee.id] = len(employee.leave_ids)
+        except:
+            pass
+        return res
+
     _columns = {
         'remaining_leaves': fields.function(_get_remaining_days, string='Remaining Legal Leaves', fnct_inv=_set_remaining_days, type="float", help='Total number of legal leaves allocated to this employee, change this value to create allocation/leave request. Total based on all the leave types without overriding limit.'),
         'current_leave_state': fields.function(_get_leave_status, multi="leave_status", string="Current Leave Status", type="selection",
@@ -557,6 +566,9 @@ class hr_employee(osv.osv):
         'current_leave_id': fields.function(_get_leave_status, multi="leave_status", string="Current Leave Type",type='many2one', relation='hr.holidays.status'),
         'leave_date_from': fields.function(_get_leave_status, multi='leave_status', type='date', string='From Date'),
         'leave_date_to': fields.function(_get_leave_status, multi='leave_status', type='date', string='To Date'),
+        'leave_ids': fields.one2many('hr.holidays', 'employee_id', 'Leaves'),
+        'leaves_count': fields.function(_leaves_count, type='integer', string='Leaves'),
+
     }
 
 
index 8a8353a..e2cb1b3 100644 (file)
@@ -982,9 +982,20 @@ class hr_employee(osv.osv):
             res[employee.id] = {'basic': result['sum']}
         return res
 
+    def _payslip_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,0), ids))
+        try:
+            for employee in self.browse(cr, uid, ids, context=context):
+                res[employee.id] = len(employee.payslip_ids)
+        except:
+            pass
+        return res
+
     _columns = {
         'slip_ids':fields.one2many('hr.payslip', 'employee_id', 'Payslips', required=False, readonly=True),
         'total_wage': fields.function(_calculate_total_wage, method=True, type='float', string='Total Basic Salary', digits_compute=dp.get_precision('Payroll'), help="Sum of all current contract's wage of employee."),
+        'payslip_count': fields.function(_payslip_count, type='integer', string='Payslips'),
+        'payslip_ids': fields.one2many('hr.payslip', 'employee_id', 'Payslips'),
     }
 
 
index 20e9e09..d82463b 100644 (file)
@@ -517,6 +517,17 @@ class hr_job(osv.osv):
                 ], context=context)
         return res
 
+    def _count_all(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,{'documents_count': 0, 'application_count': 0,}), ids))
+        try:
+            for job in self.browse(cr, uid, ids, context=context):
+                res[job.id] = {'documents_count': len(job.document_ids),
+                'application_count': len(job.applicant_ids),
+                }
+        except:
+            pass
+        return res
+
     _columns = {
         'survey_id': fields.many2one('survey', 'Interview Form', help="Choose an interview form for this job position and you will be able to print/answer this interview from all applicants who apply for this job"),
         'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True,
@@ -524,8 +535,10 @@ class hr_job(osv.osv):
                                          "create new applicants for this job position."),
         'address_id': fields.many2one('res.partner', 'Job Location', help="Address where employees are working"),
         'application_ids': fields.one2many('hr.applicant', 'job_id', 'Applications'),
+        'application_count': fields.function(_count_all, type='integer', string='Applications', multi=True),
         'manager_id': fields.related('department_id', 'manager_id', type='many2one', string='Department Manager', relation='hr.employee', readonly=True, store=True),
         'document_ids': fields.function(_get_attached_docs, type='one2many', relation='ir.attachment', string='Applications'),
+        'documents_count': fields.function(_count_all, type='integer', string='Documents', multi=True),
         'user_id': fields.many2one('res.users', 'Recruitment Responsible', track_visibility='onchange'),
         'color': fields.integer('Color Index'),
     }
index 6221d0d..22735af 100644 (file)
             <sheet>
                 <div class="oe_right oe_button_box">
                     <button name="action_makeMeeting" class="oe_stat_button" icon="fa-calendar" type="object"
-                         string="Meeting" help="Schedule interview with this applicant"/>
+                         help="Schedule interview with this applicant">
+                         <div>Schedule<br/>Meeting</div>
+                    </button>
                     <button name="%(survey.action_view_survey_question_message)d" 
                         class="oe_stat_button"
                         icon="fa-user" 
                         type="action"
-                        string="Interview" help="Answer related job question"
+                        help="Answer related job question"
                         context="{'survey_id': survey, 'response_id': [response], 'response_no':0 ,'active' : response, 'object' : 'hr.applicant'}"
-                        attrs="{'invisible':[('survey','=',False)]}"/>
+                        attrs="{'invisible':[('survey','=',False)]}">
+                        <div>Start<br/>Interview</div>
+                    </button>
                     <button name="action_print_survey" 
                         class="oe_stat_button"
                         icon="fa-print"
                         type="object"
-                        string="Print" help="Print interview report"
-                        attrs="{'invisible':[('survey','=',False)]}"/>
+                        help="Print interview report"
+                        attrs="{'invisible':[('survey','=',False)]}">
+                        <div>Print<br/>Interview</div>
+                    </button>
                     <button name="action_get_attachment_tree_view" 
                         class="oe_stat_button"
                         icon="fa-book"
index d71d083..bd574dc 100644 (file)
@@ -558,6 +558,26 @@ class res_company(osv.osv):
         'timesheet_max_difference': lambda *args: 0.0
     }
 
+class hr_employee(osv.osv):
+    '''
+    Employee
+    '''
 
+    _inherit = 'hr.employee'
+    _description = 'Employee'
+
+    def _timesheet_count(self, cr, uid, ids, field_name, arg, context=None):
+        res = dict(map(lambda x: (x,0), ids))
+        try:
+            for employee in self.browse(cr, uid, ids, context=context):
+                res[employee.id] = len(employee.timesheet_ids)
+        except:
+            pass
+        return res
+
+    _columns = {
+        'timesheet_ids': fields.one2many('hr_timesheet_sheet.sheet', 'employee_id', 'Timesheets'),
+        'timesheet_count': fields.function(_timesheet_count, type='integer', string='Timsheets'),
+    }
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: