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
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import logging
|
|
|
|
from odoo import api, fields, models
|
|
from odoo.tools import email_normalize
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class MailGroupMember(models.Model):
|
|
"""Models a group member that can be either an email address either a full partner."""
|
|
_name = 'mail.group.member'
|
|
_description = 'Mailing List Member'
|
|
_rec_name = 'email'
|
|
|
|
email = fields.Char(string='Email', compute='_compute_email', readonly=False, store=True)
|
|
email_normalized = fields.Char(
|
|
string='Normalized Email', compute='_compute_email_normalized',
|
|
index=True, store=True)
|
|
mail_group_id = fields.Many2one('mail.group', string='Group', required=True, ondelete='cascade')
|
|
partner_id = fields.Many2one('res.partner', 'Partner', ondelete='cascade')
|
|
|
|
_sql_constraints = [(
|
|
'unique_partner',
|
|
'UNIQUE(partner_id, mail_group_id)',
|
|
'This partner is already subscribed to the group',
|
|
)]
|
|
|
|
@api.depends('partner_id.email')
|
|
def _compute_email(self):
|
|
for member in self:
|
|
if member.partner_id:
|
|
member.email = member.partner_id.email
|
|
elif not member.email:
|
|
member.email = False
|
|
|
|
@api.depends('email')
|
|
def _compute_email_normalized(self):
|
|
for moderation in self:
|
|
moderation.email_normalized = email_normalize(moderation.email)
|