Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Base Tier Validation Formula

Entity: tier.review

Compute Method: _compute_python_reviewer_ids

Inputs Method Outputs
  • review_type
  • model
  • res_id
  • definition_id
  • definition_id.reviewer_expression
for rec in self:
            if rec.review_type != "expression":
                rec.python_reviewer_ids = self.env["res.users"].browse()
                continue
            record = rec.env[rec.model].browse(rec.res_id).exists()
            try:
                reviewer_ids = safe_eval(
                    rec.definition_id.reviewer_expression, {"rec": record}
                )
            except Exception as error:
                raise UserError(
                    rec.env._(
                        "Error evaluating tier validation conditions.\n %s", error
                    )
                ) from error
            # Check if python expression returns 'res.users' recordset
            if (
                not isinstance(reviewer_ids, models.Model)
                or reviewer_ids._name != "res.users"
            ):
                raise UserError(
                    rec.env._(
                        "Reviewer python expression must return a res.users recordset."
                    )
                )
            else:
                rec.python_reviewer_ids = reviewer_ids

Back to entity