[FIX] website_forum: fixed issue with user vote badly taken into account when upvotin...
[odoo/odoo.git] / addons / website_forum / models / forum.py
index 43d10c5..a34eb10 100644 (file)
@@ -401,6 +401,7 @@ class Post(osv.Model):
 
         Vote = self.pool['forum.post.vote']
         vote_ids = Vote.search(cr, uid, [('post_id', 'in', ids), ('user_id', '=', uid)], limit=1, context=context)
+        new_vote = 0
         if vote_ids:
             for vote in Vote.browse(cr, uid, vote_ids, context=context):
                 if upvote:
@@ -412,7 +413,7 @@ class Post(osv.Model):
             for post_id in ids:
                 new_vote = '1' if upvote else '-1'
                 Vote.create(cr, uid, {'post_id': post_id, 'vote': new_vote}, context=context)
-        return {'vote_count': self._get_vote_count(cr, uid, ids, None, None, context=context)[ids[0]]}
+        return {'vote_count': self._get_vote_count(cr, uid, ids, None, None, context=context)[ids[0]], 'user_vote': new_vote}
 
     def convert_answer_to_comment(self, cr, uid, id, context=None):
         """ Tools to convert an answer (forum.post) to a comment (mail.message).