| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
from odoo import api, fields, models |
| 5 |
|
| 6 |
|
| 7 |
class ForumForum(models.Model): |
| 8 |
_inherit = 'forum.forum' |
| 9 |
|
| 10 |
slide_channel_ids = fields.One2many('slide.channel', 'forum_id', 'Courses', help="Edit the course linked to this forum on the course form.") |
| 11 |
slide_channel_id = fields.Many2one('slide.channel', 'Course', compute='_compute_slide_channel_id', store=True) |
| 12 |
visibility = fields.Selection(related='slide_channel_id.visibility', help="Forum linked to a Course, the visibility is the one applied on the course.") |
| 13 |
image_1920 = fields.Image('Image', compute='_compute_image_1920', store=True, readonly=False) |
| 14 |
|
| 15 |
@api.depends('slide_channel_ids') |
| 16 |
def _compute_slide_channel_id(self): |
| 17 |
for forum in self: |
| 18 |
if forum.slide_channel_ids: |
| 19 |
forum.slide_channel_id = forum.slide_channel_ids[0] |
| 20 |
else: |
| 21 |
forum.slide_channel_id = None |
| 22 |
|
| 23 |
@api.depends('slide_channel_id', 'slide_channel_id.image_1920') |
| 24 |
def _compute_image_1920(self): |
| 25 |
for forum in self.filtered(lambda f: not f.image_1920 and f.slide_channel_id.image_1920): |
| 26 |
forum.image_1920 = forum.slide_channel_id.image_1920 |