diff options
| author | Gery Debongnie <ged@openerp.com> | 2014-05-07 11:03:28 +0200 |
|---|---|---|
| committer | Gery Debongnie <ged@openerp.com> | 2014-05-07 11:03:28 +0200 |
| commit | 943f2d4e4ed6f35c3a8a696a9b16ef04c84b8dc1 (patch) | |
| tree | 2bc9ec08d10c179e7716f7e2a3317cd00a4af825 | |
| parent | ff7ad5e9185015e0d42fd044b893ec57e883a90a (diff) | |
[FIX] code cleanup (addon hr_evaluation)
improves _appraisal_count method and remove now useless one2many field appraisal_ids
bzr revid: ged@openerp.com-20140507090328-wyl9gbfzdc540d1k
| -rw-r--r-- | addons/hr_evaluation/hr_evaluation.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/addons/hr_evaluation/hr_evaluation.py b/addons/hr_evaluation/hr_evaluation.py index 5cd960038aa..b52802cd297 100644 --- a/addons/hr_evaluation/hr_evaluation.py +++ b/addons/hr_evaluation/hr_evaluation.py @@ -104,19 +104,15 @@ class hr_employee(osv.Model): _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 - + Evaluation = self.pool['hr.evaluation.interview'] + return { + employee_id: Evaluation.search_count(cr, uid, [('user_to_review_id', '=', employee_id)], context=context) + for employee_id in ids + } _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'), } |
