diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 54a15d5593c..58ad9d9b3e0 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -240,7 +240,7 @@ class hr_evaluation(osv.osv): request_obj = self.pool.get('hr.evaluation.interview') self.write(cr, uid, ids, {'state':'progress'}, context=context) for id in self.browse(cr, uid, ids, context=context): - if len(id.survey_request_ids) != len(request_obj.search(cr, uid, [('evaluation_id', '=', id.id),('state', '=', 'done')], context=context)): + if len(id.survey_request_ids) != len(request_obj.search(cr, uid, [('evaluation_id', '=', id.id),('state', 'in', ['done','cancel'])], context=context)): raise osv.except_osv(_('Warning !'),_("You cannot change state, because some appraisal in waiting answer or draft state")) return True @@ -256,6 +256,10 @@ class hr_evaluation(osv.osv): self.write(cr, uid, ids,{'state':'cancel'}, context=context) return True + def button_draft(self, cr, uid, ids, context=None): + self.write(cr, uid, ids,{'state': 'draft'}, context=context) + return True + def write(self, cr, uid, ids, vals, context=None): if 'date' in vals: new_vals = {'date_deadline': vals.get('date')} diff --git a/addons/hr_evaluation/hr_evaluation_view.xml b/addons/hr_evaluation/hr_evaluation_view.xml index 4bf3ba0fff7..d8dfa7e40ca 100644 --- a/addons/hr_evaluation/hr_evaluation_view.xml +++ b/addons/hr_evaluation/hr_evaluation_view.xml @@ -207,6 +207,8 @@ icon="gtk-execute"/>