summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorDenis Ledoux <dle@odoo.com>2016-02-22 15:20:42 +0100
committerDenis Ledoux <dle@odoo.com>2016-02-22 15:24:34 +0100
commit3bb4ca7feefa2b6fa5dfb5c1c9c00f80a77cb55b (patch)
treef7798179f7b88630bbb7cbeb8b02a0af9ea1b9e8 /addons
parent6863cd244d374678c26e1d7402c7964e62a349be (diff)
[FIX] website_forum: avoid retag karma check if not change in tags
When a user attempted to edit his answer, and had not enough karma to edit the tags of the post, he was always restricted, even if he made no changes within the post tags. opw-670090
Diffstat (limited to 'addons')
-rw-r--r--addons/website_forum/models/forum.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py
index 24109c166a9..0b361b2e2a8 100644
--- a/addons/website_forum/models/forum.py
+++ b/addons/website_forum/models/forum.py
@@ -483,7 +483,8 @@ class Post(models.Model):
post.create_uid.sudo().add_karma(post.forum_id.karma_gen_answer_accepted * mult)
self.env.user.sudo().add_karma(post.forum_id.karma_gen_answer_accept * mult)
if 'tag_ids' in vals:
- if any(self.env.user.karma < post.forum_id.karma_edit_retag for post in self):
+ tag_ids = set(tag.get('id') for tag in self.resolve_2many_commands('tag_ids', vals['tag_ids']))
+ if any(set(post.tag_ids) != tag_ids for post in self) and any(self.env.user.karma < post.forum_id.karma_edit_retag for post in self):
raise KarmaError(_('Not enough karma to retag.'))
if any(key not in ['state', 'active', 'is_correct', 'closed_uid', 'closed_date', 'closed_reason_id', 'tag_ids'] for key in vals.keys()) and any(not post.can_edit for post in self):
raise KarmaError('Not enough karma to edit a post.')