From 112622db70aa346815bb9cee9bbaf79c4eaf8592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 22 Mar 2023 13:15:41 +0000 Subject: [PATCH] [FIX] website_forum: improve / cleanup computed fields Notably add missing triggers for unstored fields depending on 'uid'. Task-3240082 (Forum: Reorganize and lint module) Part-of: odoo/odoo#114841 --- addons/website_forum/models/forum_post.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/website_forum/models/forum_post.py b/addons/website_forum/models/forum_post.py index 490322653fa..9c4dd4c1991 100644 --- a/addons/website_forum/models/forum_post.py +++ b/addons/website_forum/models/forum_post.py @@ -185,6 +185,7 @@ class Post(models.Model): else: post.relevancy = 0 + @api.depends_context('uid') def _compute_user_vote(self): votes = self.env['forum.post.vote'].search_read([('post_id', 'in', self._ids), ('user_id', '=', self._uid)], ['vote', 'post_id']) mapped_vote = dict([(v['post_id'][0], v['vote']) for v in votes]) @@ -200,6 +201,7 @@ class Post(models.Model): for post in self: post.vote_count = result[post.id] + @api.depends_context('uid') def _compute_user_favourite(self): for post in self: post.user_favourite = post._uid in post.favourite_ids.ids @@ -212,13 +214,14 @@ class Post(models.Model): @api.depends('create_uid', 'parent_id') def _compute_self_reply(self): for post in self: - post.self_reply = post.parent_id.create_uid.id == post._uid + post.self_reply = post.parent_id.create_uid == post.create_uid @api.depends('child_ids') def _compute_child_count(self): for post in self: post.child_count = len(post.child_ids) + @api.depends_context('uid') def _compute_uid_has_answered(self): for post in self: post.uid_has_answered = post._uid in post.child_ids.create_uid.ids