diff options
| author | Dharmraj Jhala <dja@odoo.com> | 2020-08-26 10:00:36 +0000 |
|---|---|---|
| committer | Dharmraj Jhala <dja@odoo.com> | 2020-08-26 10:09:45 +0000 |
| commit | a677859a03c86bf6ac791c31f52ce8609bcba594 (patch) | |
| tree | 9c735962a033032e7f429daa2aff3844aa8fa625 /addons/website_forum | |
| parent | 0253b01632a30adfe071aa090a875fb3915e1962 (diff) | |
[FIX] website_{slides,forum}: enable slide content and forum creation
Since a recent refactoring[1] is merged, few compute methods are being
called at record creation, and throws traceback because of newID.
This commit fixes the traceback by improving the compute methods and
thus enable users to create records of slide contents and forums.
Note - compute fields should be assigned a value, and so we update
the recordset with default values while creation. See below PR for
more information.
[1] - https://github.com/odoo/odoo/pull/55995
Task - 2325605
closes odoo/odoo#56573
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/website_forum')
| -rw-r--r-- | addons/website_forum/models/forum.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index e2e74019741..1315e3ac7f3 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -145,7 +145,13 @@ class Forum(models.Model): @api.depends('post_ids.state', 'post_ids.views', 'post_ids.child_count', 'post_ids.favourite_count') def _compute_forum_statistics(self): - result = dict((cid, dict(total_posts=0, total_views=0, total_answers=0, total_favorites=0)) for cid in self.ids) + default_stats = {'total_posts': 0, 'total_views': 0, 'total_answers': 0, 'total_favorites': 0} + + if not self.ids: + self.update(default_stats) + return + + result = dict.fromkeys(self.ids, default_stats) read_group_res = self.env['forum.post'].read_group( [('forum_id', 'in', self.ids), ('state', 'in', ('active', 'close')), ('parent_id', '=', False)], ['forum_id', 'views', 'child_count', 'favourite_count'], |
