[IMP] website_forum: improve website/forum count computation
Avoid search_count in a loop using a filtered_domain. Also removed a sudo, as anyway this method is already called in sudo in most cases. Part-of: odoo/odoo#116778
This commit is contained in:
@@ -50,7 +50,6 @@ class Website(models.Model):
|
||||
websites (to update globally counters, notably when a new forum is
|
||||
created). """
|
||||
websites = self if self else self.search([])
|
||||
forums_all = self.env['forum.forum'].search([])
|
||||
for website in websites:
|
||||
website.forum_count = self.env['forum.forum'].sudo().search_count(
|
||||
website.website_domain()
|
||||
)
|
||||
website.forum_count = len(forums_all.filtered_domain(website.website_domain()))
|
||||
|
||||
Reference in New Issue
Block a user