Browse Source

make possible to filter by validated records

pull/52/head
Lois Rilo 7 years ago
committed by Naglis Jonaitis
parent
commit
095c1fa5a4
No known key found for this signature in database GPG Key ID: 4748835F585390F5
  1. 14
      base_tier_validation/models/tier_validation.py

14
base_tier_validation/models/tier_validation.py

@ -24,7 +24,10 @@ class TierValidation(models.AbstractModel):
domain=lambda self: [('model', '=', self._name)], domain=lambda self: [('model', '=', self._name)],
auto_join=True, 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") need_validation = fields.Boolean(compute="_compute_need_validation")
rejected = fields.Boolean(compute="_compute_validated_rejected") rejected = fields.Boolean(compute="_compute_validated_rejected")
reviewer_ids = fields.Many2many( reviewer_ids = fields.Many2many(
@ -40,6 +43,15 @@ class TierValidation(models.AbstractModel):
rec.reviewer_ids = rec.review_ids.filtered( rec.reviewer_ids = rec.review_ids.filtered(
lambda r: r.status == 'pending').mapped('reviewer_ids') 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 @api.model
def _search_reviewer_ids(self, operator, value): def _search_reviewer_ids(self, operator, value):
reviews = self.env['tier.review'].search([ reviews = self.env['tier.review'].search([

Loading…
Cancel
Save