From 809af8ba09a9effc7934113d31fa037e40fc4352 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 19 Jan 2015 17:33:57 +0100 Subject: [PATCH 1/2] [FIX] website_forum: no limit on user post list for moderators The limit on the list of answers and questions posted by a given forum user is purposely limited to reduce the performance penalty for displaying them all. (see 78fa86193612e6831453bba003a8045a7d3b7c6c) However seeing the full list is useful for forum moderators (e.g. when tracking down abuse), and there are only a few such users with high karma, so enabling it for them is negligible performance-wise. Fixes #3955 --- addons/website_forum/controllers/main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/website_forum/controllers/main.py b/addons/website_forum/controllers/main.py index d9411fb12c9..bce1e3a9515 100644 --- a/addons/website_forum/controllers/main.py +++ b/addons/website_forum/controllers/main.py @@ -528,16 +528,19 @@ class WebsiteForum(http.Controller): (count_user_questions and current_user.karma > forum.karma_unlink_all))): return request.website.render("website_forum.private_profile", values) - # displaying only the 20 most recent questions - user_questions = Post.browse(cr, uid, user_question_ids[:20], context=context) + # limit length of visible posts by default for performance reasons, except for the high + # karma users (not many of them, and they need it to properly moderate the forum) + post_display_limit = None + if current_user.karma < forum.karma_unlink_all: + post_display_limit = 20 + user_questions = Post.browse(cr, uid, user_question_ids[:post_display_limit], context=context) user_answer_ids = Post.search(cr, uid, [ ('parent_id', '!=', False), ('forum_id', '=', forum.id), ('create_uid', '=', user.id), ], order='create_date desc', context=context) count_user_answers = len(user_answer_ids) - # displaying only the 20 most recent answers - user_answers = Post.browse(cr, uid, user_answer_ids[:20], context=context) + user_answers = Post.browse(cr, uid, user_answer_ids[:post_display_limit], context=context) # showing questions which user following obj_ids = Followers.search(cr, SUPERUSER_ID, [('res_model', '=', 'forum.post'), ('partner_id', '=', user.partner_id.id)], context=context) From edbb14143ef55ae566b8dd4c88117e1fb11a031f Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Mon, 19 Jan 2015 20:26:31 +0100 Subject: [PATCH 2/2] [FIX] test_new_api: it works by accident but company_id <> partner_id --- openerp/addons/test_new_api/tests/test_related.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openerp/addons/test_new_api/tests/test_related.py b/openerp/addons/test_new_api/tests/test_related.py index e7ba6b8b184..b2b65e8b373 100644 --- a/openerp/addons/test_new_api/tests/test_related.py +++ b/openerp/addons/test_new_api/tests/test_related.py @@ -52,8 +52,9 @@ class TestRelatedField(common.TransactionCase): company_ids = self.company.search(self.cr, self.uid, [('partner_id', '!=', False)], limit=1) company = self.company.browse(self.cr, self.uid, company_ids[0]) - # find partners that satisfy [('partner_id.company_id', '=', company.id)] - partner_ids = self.partner.search(self.cr, self.uid, [('related_company_partner_id', '=', company.id)]) + # find partners that satisfy [('company_id.partner_id', '=', company.partner_id.id)] + partner_ids = self.partner.search(self.cr, self.uid, [('related_company_partner_id', '=', company.partner_id.id)]) + self.assertGreater(len(partner_ids), 0) partner = self.partner.browse(self.cr, self.uid, partner_ids[0]) # create a new partner, and assign it to company