From 9c7b6ef7ee8a3907f57485ab6f2e53746fb117cd Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Fri, 2 Mar 2018 16:39:09 +0100 Subject: [PATCH] make possible to filter by validated records --- base_tier_validation/models/tier_validation.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/base_tier_validation/models/tier_validation.py b/base_tier_validation/models/tier_validation.py index fc97f09..ce9763d 100644 --- a/base_tier_validation/models/tier_validation.py +++ b/base_tier_validation/models/tier_validation.py @@ -24,7 +24,10 @@ class TierValidation(models.AbstractModel): domain=lambda self: [('model', '=', self._name)], auto_join=True, ) - validated = fields.Boolean(compute="_compute_validated_rejected") + validated = fields.Boolean( + compute="_compute_validated_rejected", + search="_search_validated", + ) need_validation = fields.Boolean(compute="_compute_need_validation") rejected = fields.Boolean(compute="_compute_validated_rejected") reviewer_ids = fields.Many2many( @@ -40,6 +43,15 @@ class TierValidation(models.AbstractModel): rec.reviewer_ids = rec.review_ids.filtered( lambda r: r.status == 'pending').mapped('reviewer_ids') + @api.model + def _search_validated(self, operator, value): + assert operator in ('=', '!='), 'Invalid domain operator' + assert value in (True, False), 'Invalid domain value' + pos = self.search([ + (self._state_field, 'in', self._state_from)]).filtered( + lambda r: r.review_ids and r.validated == value) + return [('id', 'in', pos.ids)] + @api.model def _search_reviewer_ids(self, operator, value): reviews = self.env['tier.review'].search([