diff options
| author | Xavier-Do <xdo@odoo.com> | 2019-04-12 13:21:18 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-05-29 13:34:32 +0000 |
| commit | de7c119e666d108564b3889d1c08e5bf2e4da082 (patch) | |
| tree | 3c24844df7072ba840d93fb1f2b141ad7a507fa3 /addons/website_forum/models/forum.py | |
| parent | 2fcb3c658df3e504b92ff9b5a805d150cfa7effd (diff) | |
[IMP] mail: reduce message_post query count and clean code
Purpose of this commit is to improve performance of post and notify through
various code improvements.
Containing
* making of _notify_customize_recipients a mail.thread method;
* _message_auto_subscribe_followers optimized;
* renaming and optimisation of _notify_partners;
* message_post_attachements optization;
* remove unused mail_post_autofollow_partner_ids context key;
* minimize message create queries;
* only check record related access right for thread messages not in pending
moderation;
* get attachements from values instead of db;
* storing lang in ctx from the beginning;
* don't track on write on attachments;
Related to task 1943901
Linked to PR #32404
Diffstat (limited to 'addons/website_forum/models/forum.py')
| -rw-r--r-- | addons/website_forum/models/forum.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index b2673a24351..4ec595516a5 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -422,12 +422,13 @@ class Post(models.Model): return post @api.model - def check_mail_message_access(self, res_ids, operation, model_name=None): + def get_mail_message_access(self, res_ids, operation, model_name=None): + # XDO FIXME: to be correctly fixed with new get_mail_message_access and filter access rule if operation in ('write', 'unlink') and (not model_name or model_name == 'forum.post'): # Make sure only author or moderator can edit/delete messages if any(not post.can_edit for post in self.browse(res_ids)): raise KarmaError('Not enough karma to edit a post.') - return super(Post, self).check_mail_message_access(res_ids, operation, model_name=model_name) + return super(Post, self).get_mail_message_access(res_ids, operation, model_name=model_name) @api.multi def write(self, vals): @@ -805,14 +806,14 @@ class Post(models.Model): return super(Post, self).message_post(message_type=message_type, **kwargs) @api.multi - def _notify_customize_recipients(self, message, msg_vals, recipients_vals): + def _notify_customize_recipients(self, message, msg_vals): """ Override to avoid keeping all notified recipients of a comment. We avoid tracking needaction on post comments. Only emails should be sufficient. """ msg_type = msg_vals.get('message_type') or message.message_type if msg_type == 'comment': return {'needaction_partner_ids': [], 'partner_ids': []} - return {} + return super(Post, self)._notify_customize_recipients(message, msg_vals) class PostReason(models.Model): |
