forked from Viindoo/odoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] website_forum: fix tag posts count dependencies
Post counts were not updated when a post was created or deleted because of missing dependencies in the _compute. Note that while "active_test" is included when counting without specifying it, the field must be explicitly added to the `_compute`'s dependency list to trigger it. Task-3358143 closes odoo#125860 X-original-commit: f09291d Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
from . import common | ||
from . import test_forum | ||
from . import test_forum_process | ||
from . import test_forum_tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# Part of Odoo. See LICENSE file for full copyright and licensing details. | ||
|
||
from odoo.addons.website_forum.tests.common import TestForumCommon | ||
|
||
|
||
class TestForumTag(TestForumCommon): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.env['forum.tag'].search([]).unlink() | ||
cls.tags = cls.env['forum.tag'].create( | ||
[{'forum_id': cls.forum.id, 'name': f'Test Tag {tag_idx}'} for tag_idx in range(1, 3)] | ||
) | ||
cls.env['forum.post'].create( | ||
[{'name': 'Posting about tag 1', 'forum_id': cls.forum.id, 'tag_ids': [[6, 0, [cls.tags[0].id]]]}] | ||
) | ||
|
||
def _check_tags_post_counts(self, tags, expected_counts): | ||
self.assertEqual(tags.mapped('posts_count'), expected_counts) | ||
|
||
def test_tag_posts_count(self): | ||
self._check_tags_post_counts(self.tags, [1, 0]) | ||
post_tag_1 = self.env['forum.post'].create( | ||
[{'name': 'Posting about tag 1 again', 'forum_id': self.forum.id, 'tag_ids': [[6, 0, [self.tags[0].id]]]}] | ||
) | ||
self._check_tags_post_counts(self.tags, [2, 0]) | ||
post_tags = self.env['forum.post'].create( | ||
[{'name': 'Posting about tag 2 now', 'forum_id': self.forum.id, 'tag_ids': [[6, 0, self.tags.ids]]}] | ||
) | ||
self._check_tags_post_counts(self.tags, [3, 1]) | ||
post_tag_1.active = False | ||
self._check_tags_post_counts(self.tags, [2, 1]) | ||
post_tags.close(None) | ||
self._check_tags_post_counts(self.tags, [1, 0]) |