Files
odoo_source/addons/website_slides_forum/models/forum.py
T
jbm-odoo 49d64a8fb1 [IMP] website_forum: Add privacy
Add privacy on forum: public or private. If private, we must select
one group that has access.

For forum linked to eLearning course: the privacy of forum is the same
as the course. If the course is not yet published, the forum will be
invisible (unless we have the group group_website_slides_officer).

If a forum linked to a course is unlinked or removed, the forum will
become private and his group will be set to group_website_slides_officer.

All posts and tags have the same access rules as their linked forum.

closes odoo/odoo#43486

Taskid: 2169965
Related: odoo/upgrade#758
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-02-28 08:58:43 +00:00

21 lines
891 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class Forum(models.Model):
_inherit = 'forum.forum'
slide_channel_ids = fields.One2many('slide.channel', 'forum_id', 'Courses', help="Edit the course linked to this forum on the course form.")
slide_channel_id = fields.Many2one('slide.channel', 'Course', compute='_compute_slide_channel_id', store=True)
visibility = fields.Selection(related='slide_channel_id.visibility', help="Forum linked to a Course, the visibility is the one applied on the course.")
@api.depends('slide_channel_ids')
def _compute_slide_channel_id(self):
for forum in self:
if forum.slide_channel_ids:
forum.slide_channel_id = forum.slide_channel_ids[0]
else:
forum.slide_channel_id = None