Purpose ======= The purpose of this new module is to manage the mailing lists. Now they are no more <mail.channel> (will email_send set to True) but they have their own model. Specifications ============== The mailing list are basically a public discussion that users can have by email. They can respond to email, send new messages, etc... All the members of the mailing list will receive the message by email. Users can moderate the emails of the mailing list in the same way as they did with the "email" mail channel. - *accept*, will accept the emails and send it to the members of the mailing list - *discard*, will drop the email without warning the author - *reject*, will drop the email and send a notification email to the author - *allow*, will accept the email and all other pending emails of the same author and create a whitelist for him - *ban* will drop the email and all other pending emails of the same author and create a blacklist for him Now a portal view is available (in /groups) and replace the old module "Website Mail Channel" that was removed in the previous commit. In this view, users can subscribe / unsubscribe to the mailing lists and some links to this portal view are added in the footer of the emails of the mailing list. As before with mail channels, you can send guidelines to the members, notify the moderators whose an action is required (in a CRON), send back an email to the author of an email to say "Your message is waiting moderation"... Links ===== Task-2510267 See odoo/odoo/pull/71599 See odoo/enterprise/pull/19296 See odoo/upgrade/pull/2600
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import fields, models, api, _
|
|
from odoo.exceptions import UserError
|
|
from odoo.tools import email_normalize
|
|
|
|
|
|
class MailGroupModeration(models.Model):
|
|
"""Represent the moderation rules for an email address in a group."""
|
|
_name = 'mail.group.moderation'
|
|
_description = 'Mailing List black/white list'
|
|
|
|
email = fields.Char(string='Email', required=True)
|
|
status = fields.Selection(
|
|
[('allow', 'Always Allow'), ('ban', 'Permanent Ban')],
|
|
string='Status', required=True, default='ban')
|
|
mail_group_id = fields.Many2one('mail.group', string='Group', required=True, ondelete='cascade')
|
|
|
|
_sql_constraints = [(
|
|
'mail_group_email_uniq',
|
|
'UNIQUE(mail_group_id, email)',
|
|
'You can create only one rule for a given email address in a group.',
|
|
)]
|
|
|
|
@api.model_create_multi
|
|
def create(self, vals_list):
|
|
for values in vals_list:
|
|
email_normalized = email_normalize(values.get('email'))
|
|
if not email_normalized:
|
|
raise UserError(_('Invalid email address %r', values.get('email')))
|
|
values['email'] = email_normalized
|
|
return super(MailGroupModeration, self).create(vals_list)
|
|
|
|
def write(self, values):
|
|
if 'email' in values:
|
|
email_normalized = email_normalize(values['email'])
|
|
if not email_normalized:
|
|
raise UserError(_('Invalid email address %r', values.get('email')))
|
|
values['email'] = email_normalized
|
|
return super(MailGroupModeration, self).write(values)
|