[REF] mail: remove is_subscribed duplicated field on mail.channel

RATIONALE

Channel model is a mail.thread enabled model behaving strangely with followers,
notifications and discuss. Its code should however be simplified to be more
self contained and avoid unwanted side effects on other models.

SPECIFICATION

Channel holds two fields computing current user's membership on channel.
``is_subscribed`` is a duplicate of ``is_member``. It is therefore removed
to keep a single field.

LINKS

Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
This commit is contained in:
Thibault Delavallée
2021-03-17 18:07:15 +00:00
parent 74dc9795f5
commit 10af1a949b
2 changed files with 3 additions and 10 deletions
-7
View File
@@ -59,8 +59,6 @@ class Channel(models.Model):
'mail.message', 'mail_message_mail_channel_rel',
string='Channel Messages')
is_member = fields.Boolean('Is a member', compute='_compute_is_member')
is_subscribed = fields.Boolean(
'Is Subscribed', compute='_compute_is_subscribed')
group_ids = fields.Many2many(
'res.groups', string='Auto Subscription',
help="Members of those groups will automatically added as followers. "
@@ -107,11 +105,6 @@ class Channel(models.Model):
for record in self:
record.is_member = record in membership_ids
@api.depends('channel_partner_ids')
def _compute_is_subscribed(self):
for channel in self:
channel.is_subscribed = self.env.user.partner_id in channel.channel_partner_ids
@api.depends('moderator_ids')
def _compute_is_moderator(self):
for channel in self:
+3 -3
View File
@@ -10,7 +10,7 @@
<kanban>
<field name="id"/>
<field name="description"/>
<field name="is_subscribed"/>
<field name="is_member"/>
<field name="group_ids"/>
<field name="public"/>
<templates>
@@ -27,8 +27,8 @@
<p class="oe_module_name">
<field name="description"/>
</p>
<button type="object" attrs="{'invisible':['|', ('is_subscribed','=',True), ('group_ids', '!=', [])]}" class="btn btn-primary float-right" name="channel_join_and_get_info">Join</button>
<button type="object" attrs="{'invisible':['|', ('is_subscribed','=',False), ('group_ids', '!=', [])]}" class="btn btn-secondary float-right" name="action_unfollow">Leave</button>
<button type="object" attrs="{'invisible':['|', ('is_member','=',True), ('group_ids', '!=', [])]}" class="btn btn-primary float-right" name="channel_join_and_get_info">Join</button>
<button type="object" attrs="{'invisible':['|', ('is_member','=',False), ('group_ids', '!=', [])]}" class="btn btn-secondary float-right" name="action_unfollow">Leave</button>
</div>
</div>
</t>