PURPOSE Allow alias domains to be multiple, notably to be used in a multi company environment where each company has its own alias domain. SPECIFICATIONS Add a new 'mail.alias.domain' model storing information previously stored as a unique value in 'mail.catchall.domain' configuration parameter. Domains are not completely linked to companies, allowing to have a mono-domain MC setup, or mono-company multi-domain setup. A main email domain is present on companies for all default domain computation when being in that company while keeping flexibility of having other domains defined. Now that a new 'mail.alias.domain' model exists we move bounce and catchall aliases definition directly on this model. Update related computation on company model. Default_from is also moved on this model, allowing an higher level default from computation for mail servers when having knowledge of alias domain environment. Filtering configuration based on default_from_filter is kept as an ICP as it is mainly used for odoo-bin with smtp-host. Usage of 'mail.catchall.domain' will soon be completely removed to be replaced by proposed company-based email alias domain usage. Constraints are added so that each bounce and catchall defined on domains do not clash with existing aliases. Sanitize of bounce and catchall is also performed to ensure they make valid emails. This matches previous behavior of ICP parameters. Domain name is also sanitized like alias names. Currently only base modeling and computation is done. Their usage is about to be gradually added in mail stack. LINKS Task-36879 (Mail: Support Multi Domains Aliases) Part-of: odoo/odoo#76734
31 lines
1.4 KiB
Python
31 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, models
|
|
|
|
|
|
class IrConfigParameter(models.Model):
|
|
_inherit = 'ir.config_parameter'
|
|
|
|
@api.model
|
|
def set_param(self, key, value):
|
|
if key == 'mail.restrict.template.rendering':
|
|
group_user = self.env.ref('base.group_user')
|
|
group_mail_template_editor = self.env.ref('mail.group_mail_template_editor')
|
|
|
|
if not value and group_mail_template_editor not in group_user.implied_ids:
|
|
group_user.implied_ids |= group_mail_template_editor
|
|
|
|
elif value and group_mail_template_editor in group_user.implied_ids:
|
|
# remove existing users, including inactive template user
|
|
# admin will regain the right via implied_ids on group_system
|
|
group_user._remove_group(group_mail_template_editor)
|
|
# sanitize, normalize; note that False = unlink ICP
|
|
elif key in {'mail.bounce.alias', 'mail.catchall.alias'} and value:
|
|
value = self.env['mail.alias']._sanitize_alias_name(value)
|
|
# sanitize and normalize allowed catchall domains
|
|
elif key == 'mail.catchall.domain.allowed' and value:
|
|
value = self.env['mail.alias']._clean_and_check_mail_catchall_allowed_domains(value)
|
|
|
|
return super().set_param(key, value)
|