From 6bf1bd7c7e4678b63bea10654bb6839e82df3434 Mon Sep 17 00:00:00 2001 From: bosd Date: Mon, 23 Oct 2023 00:00:37 +0200 Subject: [PATCH] [FIX]base_tier_validation_report: fix ci, make computable field non stored --- .../models/tier_review.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/base_tier_validation_report/models/tier_review.py b/base_tier_validation_report/models/tier_review.py index fb5be48d21..64bec97026 100644 --- a/base_tier_validation_report/models/tier_review.py +++ b/base_tier_validation_report/models/tier_review.py @@ -10,7 +10,7 @@ class TierReview(models.Model): resource_ref = fields.Reference( selection="_selection_resource_ref", compute="_compute_resource_ref", - store=True, + store=False, readonly=True, compute_sudo=True, ) @@ -27,6 +27,7 @@ class TierReview(models.Model): compute_sudo=True, ) + @api.model def _selection_resource_ref(self): models = self.env["tier.definition"]._get_tier_validation_model_names() res = [(m, self.env[m]._description) for m in models] @@ -35,12 +36,16 @@ def _selection_resource_ref(self): @api.depends("model", "res_id") def _compute_resource_ref(self): for rec in self: - rec.resource_ref = ( - "%s,%s" % (rec.model, rec.res_id) if rec.res_id else False - ) - rec.resource_name = rec.resource_ref.display_name - rec.resource_type = rec.model - rec.next_review = rec.resource_ref.next_review + if rec.model and rec.model in self.env: + rec.resource_ref = "%s,%s" % ( + rec.model, + rec.res_id, + ) # if rec.res_id else False + rec.resource_name = rec.resource_ref.display_name + rec.resource_type = rec.model + rec.next_review = rec.resource_ref.next_review + else: + rec.resource_ref = None def action_open_resource_ref(self): self.ensure_one()