From af692af8c6370bfabf01e44e8b167e01addedb88 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Wed, 10 Apr 2019 13:55:25 +0200 Subject: [PATCH] [IMP] base_tier_validation: Pass parameters as functions --- base_tier_validation/models/tier_review.py | 11 +++++++++-- base_tier_validation_formula/models/tier_review.py | 14 +++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/base_tier_validation/models/tier_review.py b/base_tier_validation/models/tier_review.py index 74dd5a4..8eb8777 100644 --- a/base_tier_validation/models/tier_review.py +++ b/base_tier_validation/models/tier_review.py @@ -41,8 +41,15 @@ class TierReview(models.Model): ) reviewed_date = fields.Datetime(string='Validation Date') + @api.model + def _get_reviewer_fields(self): + return ['reviewer_id', 'reviewer_group_id', 'reviewer_group_id.users'] + @api.multi - @api.depends('reviewer_id', 'reviewer_group_id', 'reviewer_group_id.users') + @api.depends(lambda self: self._get_reviewer_fields()) def _compute_reviewer_ids(self): for rec in self: - rec.reviewer_ids = rec.reviewer_id + rec.reviewer_group_id.users + rec.reviewer_ids = rec._get_reviewers() + + def _get_reviewers(self): + return self.reviewer_id + self.reviewer_group_id.users diff --git a/base_tier_validation_formula/models/tier_review.py b/base_tier_validation_formula/models/tier_review.py index 6a128dd..b1889c3 100644 --- a/base_tier_validation_formula/models/tier_review.py +++ b/base_tier_validation_formula/models/tier_review.py @@ -14,13 +14,13 @@ class TierReview(models.Model): compute="_compute_python_reviewer_ids", store=True ) - @api.depends('reviewer_id', 'reviewer_group_id', 'reviewer_group_id.users', - 'python_reviewer_ids') - def _compute_reviewer_ids(self): - super(TierReview, self)._compute_reviewer_ids() - for rec in self: - rec.reviewer_ids = rec.reviewer_id + rec.reviewer_group_id.users \ - + rec.python_reviewer_ids + @api.model + def _get_reviewer_fields(self): + res = super()._get_reviewer_fields() + return res + ['python_reviewer_ids'] + + def _get_reviewers(self): + return super()._get_reviewers() + self.python_reviewer_ids @api.multi @api.depends('definition_id.reviewer_expression',