From f0c1eb17866f2d378bc4353247653ec58386a789 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 15 May 2014 10:57:51 +0200 Subject: [PATCH] [FIX] website_forum: execute the change of number of views in SQL instead of using the orm Using sql will be faster (doing a write in a read is never a good idea for performances) and will not update the write_date (which is used for the last activity filter) --- addons/website_forum/models/forum.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 061b9e55eb8..b1de4c001a5 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -269,8 +269,7 @@ class Post(osv.Model): return {'vote_count': self._get_vote_count(cr, uid, ids, None, None, context=context)[ids[0]]} def set_viewed(self, cr, uid, ids, context=None): - for post in self.browse(cr, uid, ids, context=context): - self.write(cr, uid, [post.id], {'views': post.views + 1}, context=context) + cr.execute("""UPDATE forum_post SET views = views+1 WHERE id IN %s""", (tuple(ids),)) return True