[IMP] mail: protect by default alias of private or group based channels
Otherwise by default their alias are public. This makes no sense for private groups to have by default public aliases. Field is set as invisible on the view because it makes sense to configure only the channel and not details of its alias. Anyway it is always possible to tweak the alias configuration under Technical menu.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -106,8 +106,7 @@
|
||||
<field name="alias_name" class="oe_inline"/>@<field name="alias_domain" class="oe_inline" readonly="1"/>
|
||||
</div>
|
||||
</div>
|
||||
<label for="alias_contact" string=" " class="fa fa-lock" style="min-width: 20px;"/>
|
||||
<field name="alias_contact" class="oe_inline" nolabel="1"/>
|
||||
<field name="alias_contact" class="oe_inline" invisible="1"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Privacy">
|
||||
|
||||
Reference in New Issue
Block a user