Files
odoo_source/addons/website_slides/models/slide_embed.py
T
Goffin Simon 4cdd82b52b [FIX] website_slides: Impossible to delete a slide
Steps to reproduce the issue:

- Create a presentation in a course (model `slide.slide`)
- Create an entry referencing the presentation in `slide_embed` table
- Remove the presentation from the course and save the changes

Bug:

A validation error was raised

opw:2902062

closes odoo/odoo#99468

X-original-commit: e5c239fcef2ee29856428c8f0d337fffc0a22e56
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Simon Goffin <sig@odoo.com>
2022-09-15 20:17:50 +02:00

24 lines
857 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, api, fields, models
class EmbeddedSlide(models.Model):
""" Embedding in third party websites. Track view count, generate statistics. """
_name = 'slide.embed'
_description = 'Embedded Slides View Counter'
_rec_name = 'website_name'
slide_id = fields.Many2one(
'slide.slide', string="Presentation",
required=True, index=True, ondelete='cascade')
url = fields.Char('Third Party Website URL')
website_name = fields.Char('Website', compute='_compute_website_name')
count_views = fields.Integer('# Views', default=1)
@api.depends('url')
def _compute_website_name(self):
for slide_embed in self:
slide_embed.website_name = slide_embed.url or _('Unknown Website')