~openerp-dev/openobject-addons/acct_prj_hr_logs

« back to all changes in this revision

Viewing changes to hr_evaluation/hr_evaluation.py

  • Committer: pap(openerp)
  • Date: 2010-06-21 05:19:03 UTC
  • mfrom: (3638.1.26 trunk-dev-addons3)
  • Revision ID: pap@tinyerp.co.in-20100621051903-lm0gpjuehqakpntg
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    _columns = {
50
50
        'name': fields.char("Phase", size=64, required=True),
51
51
        'sequence': fields.integer("Sequence"),
52
 
        'company_id': fields.related('plan_id','company_id',type='many2one',relation='res.company',string='Company',store=True),
 
52
        'company_id': fields.related('plan_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True),
53
53
        'plan_id': fields.many2one('hr_evaluation.plan','Evaluation Plan', required=True, ondelete='cascade'),
54
54
        'action': fields.selection([
55
55
            ('top-down','Top-Down Appraisal Requests'),
68
68
        'wait': fields.boolean('Wait Previous Phases',
69
69
            help="Check this box if you want to wait that all preceeding phases " +
70
70
              "are finished before launching this phase."),
71
 
        'mail_feature': fields.boolean('Send mail for this phase',help="Check this box if you want to send mail to employees"+
 
71
        'mail_feature': fields.boolean('Send mail for this phase', help="Check this box if you want to send mail to employees"+
72
72
                                       "coming under this phase"),
73
73
        'mail_body': fields.text('Email'),
74
74
        'email_subject':fields.text('char')
105
105
    }
106
106
 
107
107
    def run_employee_evaluation(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
108
 
        for id in self.browse(cr, uid, self.search(cr, uid, [],context=context),context=context):
 
108
        for id in self.browse(cr, uid, self.search(cr, uid, [], context=context), context=context):
109
109
            if id.evaluation_plan_id and id.evaluation_date:
110
110
                if (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months = int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d') <= time.strftime("%Y-%m-%d"):
111
 
                    self.write(cr, uid, id.id, {'evaluation_date' : (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months =+ int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d')},context=context)
112
 
                    self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id.id, 'plan_id': id.evaluation_plan_id},context)
 
111
                    self.write(cr, uid, id.id, {'evaluation_date' : (dt.ISO.ParseAny(id.evaluation_date) + dt.RelativeDateTime(months =+ int(id.evaluation_plan_id.month_next))).strftime('%Y-%m-%d')}, context=context)
 
112
                    self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id.id, 'plan_id': id.evaluation_plan_id}, context)
113
113
        return True
114
114
 
115
115
    def onchange_evaluation_plan_id(self, cr, uid, ids, evaluation_plan_id, evaluation_date, context={}):
117
117
        evaluation_plan_obj=self.pool.get('hr_evaluation.plan')
118
118
        if evaluation_plan_id:
119
119
            flag = False
120
 
            evaluation_plan =  evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id],context=context)[0]
 
120
            evaluation_plan =  evaluation_plan_obj.browse(cr, uid, [evaluation_plan_id], context=context)[0]
121
121
            if not evaluation_date:
122
122
               evaluation_date=(dt.ISO.ParseAny(dt.now().strftime('%Y-%m-%d'))+ dt.RelativeDateTime(months=+evaluation_plan.month_first)).strftime('%Y-%m-%d')
123
123
               flag = True
126
126
                    evaluation_date=(dt.ISO.ParseAny(evaluation_date)+ dt.RelativeDateTime(months=+evaluation_plan.month_next)).strftime('%Y-%m-%d')
127
127
                    flag = True
128
128
            if ids and flag:
129
 
                self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : ids[0], 'plan_id': evaluation_plan_id},context=context)
 
129
                self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : ids[0], 'plan_id': evaluation_plan_id}, context=context)
130
130
        return {'value': {'evaluation_date':evaluation_date}}
131
131
 
132
132
    def create(self, cr, uid, vals, context={}):
133
133
        id = super(hr_employee, self).create(cr, uid, vals, context=context)
134
134
        if vals.get('evaluation_plan_id', False):
135
 
            self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']},context=context)
 
135
            self.pool.get("hr_evaluation.evaluation").create(cr, uid, {'employee_id' : id, 'plan_id': vals['evaluation_plan_id']}, context=context)
136
136
        return id
137
137
 
138
138
hr_employee()
163
163
            ('progress','Final Validation'),
164
164
            ('done','Done'),
165
165
            ('cancel','Cancelled'),
166
 
        ], 'State', required=True,readonly=True),
 
166
        ], 'State', required=True, readonly=True),
167
167
        'date_close': fields.date('Ending Date'),
168
168
        'progress' : fields.float("Progress"),
169
169
    }
172
172
        'state' : lambda *a: 'draft',
173
173
    }
174
174
 
175
 
    def onchange_employee_id(self,cr,uid,ids,employee_id,context={}):
 
175
    def onchange_employee_id(self, cr, uid, ids, employee_id, context={}):
176
176
        employee_obj=self.pool.get('hr.employee')
177
177
        evaluation_plan_id=''
178
178
        if employee_id:
179
 
            for employee in employee_obj.browse(cr,uid,[employee_id],context=context):
 
179
            for employee in employee_obj.browse(cr, uid, [employee_id], context=context):
180
180
                if employee and employee.evaluation_plan_id and employee.evaluation_plan_id.id:
181
181
                    evaluation_plan_id=employee.evaluation_plan_id.id
182
 
                employee_ids=employee_obj.search(cr,uid,[('parent_id','=',employee.id)],context=context)
 
182
                employee_ids=employee_obj.search(cr, uid, [('parent_id','=',employee.id)], context=context)
183
183
        return {'value': {'plan_id':evaluation_plan_id}}
184
184
 
185
 
    def button_plan_in_progress(self,cr, uid, ids, context={}):
 
185
    def button_plan_in_progress(self, cr, uid, ids, context={}):
186
186
        apprai_id = []
187
 
        for evaluation in self.browse(cr,uid,ids, context):
 
187
        for evaluation in self.browse(cr, uid, ids, context):
188
188
            wait = False
189
189
            for phase in evaluation.plan_id.phase_ids:
190
190
                childs = []
223
223
                        sub = phase.email_subject
224
224
                        dest = [child.work_email]
225
225
                        if dest:
226
 
                           tools.email_send(src,dest,sub,body)
 
226
                           tools.email_send(src, dest, sub, body)
227
227
 
228
 
        self.write(cr,uid,ids,{'state':'wait'},context=context)
 
228
        self.write(cr, uid, ids, {'state':'wait'}, context=context)
229
229
        return True
230
230
 
231
 
    def button_final_validation(self,cr, uid, ids, context={}):
232
 
        self.write(cr,uid,ids,{'state':'progress'})
 
231
    def button_final_validation(self, cr, uid, ids, context={}):
 
232
        self.write(cr, uid, ids, {'state':'progress'})
233
233
        request_obj = self.pool.get('hr.evaluation.interview')
234
234
        for id in self.browse(cr, uid ,ids,context=context):
235
235
            if len(id.survey_request_ids) != len(request_obj.search(cr, uid, [('evaluation_id', '=', id.id),('state', '=', 'done')],context=context)):
240
240
        self.write(cr,uid,ids,{'state':'done', 'date_close': time.strftime('%Y-%m-%d')}, context=context)
241
241
        return True
242
242
 
243
 
    def button_cancel(self,cr, uid, ids, context={}):
244
 
        self.write(cr,uid,ids,{'state':'cancel'}, context=context)
 
243
    def button_cancel(self, cr, uid, ids, context={}):
 
244
        self.write(cr, uid, ids,{'state':'cancel'}, context=context)
245
245
        return True
246
246
 
247
247
hr_evaluation()