summaryrefslogtreecommitdiff
path: root/addons/website_mail/models
diff options
context:
space:
mode:
authorJérome Maes <jem@openerp.com>2016-12-26 11:32:25 +0100
committerJérome Maes <jem@openerp.com>2017-06-30 11:06:32 +0200
commitd79678fdd5faccffff65a439653fa5d639a3d3c4 (patch)
tree7cb3f4a849289dbae3983daefea02c6cbbd21467 /addons/website_mail/models
parent890e665b882b27184003cc5de6ad365f2910815d (diff)
[IMP] website_mail: make the frontend chatter lazy
Message are now fetched and display using javascript to optimize performance. Also the chatter is completely rewrite : add pager, filter possiblity, ... This commit is mainly technical: posting feature does not change. Only the display with pager is new. The goal is also to prepare frontend chatter for a better integration with rating widget. The mail.thread mixin is extended to manage the field website_message_ids (display all messages that can be seen on frontend by user (employee or not). When fetching or posting message, a check is done to see if we need to do it as sudo(). website_mail implement posting messages with token or sha_in (using in website_quote). The same verification is now done when fetching messages, via '_special_access_object' method.
Diffstat (limited to 'addons/website_mail/models')
-rw-r--r--addons/website_mail/models/mail_message.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/website_mail/models/mail_message.py b/addons/website_mail/models/mail_message.py
index d5e12e41b0b..f1ebde86c2a 100644
--- a/addons/website_mail/models/mail_message.py
+++ b/addons/website_mail/models/mail_message.py
@@ -56,3 +56,15 @@ class MailMessage(models.Model):
if self.env.cr.fetchall():
raise AccessError(_('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % (self._description, operation))
return super(MailMessage, self).check_access_rule(operation=operation)
+
+ @api.multi
+ def website_message_format(self):
+ message_values = self.read([
+ 'id', 'body', 'date', 'author_id', 'email_from', # base message fields
+ 'message_type', 'subtype_id', 'subject', # message specific
+ 'model', 'res_id', 'record_name', # document related
+ 'website_published',
+ ])
+ message_tree = dict((m.id, m) for m in self.sudo())
+ self._message_read_dict_postprocess(message_values, message_tree)
+ return message_values