diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index 29f0e927978..6012dc9c22b 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -43,6 +43,13 @@ class Channel(models.Model):
image_path = modules.get_module_resource('mail', 'static/src/img', 'groupdefault.png')
return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
+ @api.model
+ def default_get(self, fields):
+ res = super(Channel, self).default_get(fields)
+ if not res.get('alias_contact') and (not fields or 'alias_contact' in fields):
+ res['alias_contact'] = 'everyone' if res.get('public', 'private') == 'public' else 'followers'
+ return res
+
name = fields.Char('Name', required=True, translate=True)
channel_type = fields.Selection([
('chat', 'Chat Discussion'),
@@ -99,6 +106,13 @@ class Channel(models.Model):
for record in self:
record.is_member = record in membership_ids
+ @api.onchange('public')
+ def _onchange_public(self):
+ if self.public == 'public':
+ self.alias_contact = 'everyone'
+ else:
+ self.alias_contact = 'followers'
+
@api.model
def create(self, vals):
tools.image_resize_images(vals)
diff --git a/addons/mail/views/mail_channel_views.xml b/addons/mail/views/mail_channel_views.xml
index 0c1ed4a8ce9..58c6d724a4f 100644
--- a/addons/mail/views/mail_channel_views.xml
+++ b/addons/mail/views/mail_channel_views.xml
@@ -106,8 +106,7 @@
@
-
-
+