diff options
Diffstat (limited to 'addons/website_mail/models/mail_message.py')
| -rw-r--r-- | addons/website_mail/models/mail_message.py | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/addons/website_mail/models/mail_message.py b/addons/website_mail/models/mail_message.py deleted file mode 100644 index 2de32b9f4f0..00000000000 --- a/addons/website_mail/models/mail_message.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, fields, models, _ -from odoo.osv import expression -from odoo.exceptions import AccessError - - -class MailMessage(models.Model): - _inherit = 'mail.message' - - @api.model - def default_get(self, fields_list): - defaults = super(MailMessage, self).default_get(fields_list) - - # Note: explicitly implemented in default_get() instead of field default, - # to avoid setting to True for all existing messages during upgrades. - # TODO: this default should probably be dynamic according to the model - # on which the messages are attached, thus moved to create(). - if 'website_published' in fields_list: - defaults.setdefault('website_published', True) - - return defaults - - website_published = fields.Boolean(string='Published', help="Visible on the website as a comment", copy=False) - - @api.model - def _non_employee_message_domain(self): - domain = super(MailMessage, self)._non_employee_message_domain() - return expression.AND([domain, [('website_published', '=', True)]]) - - @api.model - def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None): - """ Override that adds specific access rights of mail.message, to restrict - messages to published messages for public users. """ - if self.user_has_groups('base.group_public'): - args = expression.AND([[('website_published', '=', True)], list(args)]) - - return super(MailMessage, self)._search(args, offset=offset, limit=limit, order=order, - count=count, access_rights_uid=access_rights_uid) - - def check_access_rule(self, operation): - """ Add Access rules of mail.message for non-employee user: - - read: - - raise if the type is comment and subtype NULL (internal note) - """ - if self.user_has_groups('base.group_public'): - self.env.cr.execute('SELECT id FROM "%s" WHERE website_published IS FALSE AND id = ANY (%%s)' % (self._table), (self.ids,)) - 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) - + ' - ({} {}, {} {})'.format(_('Records:'), self.ids[:6], _('User:'), self._uid) - ) - return super(MailMessage, self).check_access_rule(operation=operation) - - def _portal_message_format(self, fields_list): - fields_list += ['website_published'] - return super(MailMessage, self)._portal_message_format(fields_list) |
