diff --git a/addons/website_slides/models/slide_channel.py b/addons/website_slides/models/slide_channel.py index 60e74c019b6..338d71f16da 100644 --- a/addons/website_slides/models/slide_channel.py +++ b/addons/website_slides/models/slide_channel.py @@ -11,6 +11,7 @@ from odoo import api, fields, models, tools, _ from odoo.addons.http_routing.models.ir_http import slug from odoo.exceptions import AccessError from odoo.osv import expression +from odoo.tools import is_html_empty _logger = logging.getLogger(__name__) @@ -148,8 +149,8 @@ class Channel(models.Model): # description name = fields.Char('Name', translate=True, required=True) active = fields.Boolean(default=True, tracking=100) - description = fields.Text('Description', translate=True, help="The description that is displayed on top of the course page, just below the title") - description_short = fields.Text('Short Description', translate=True, help="The description that is displayed on the course card") + description = fields.Html('Description', translate=True, help="The description that is displayed on top of the course page, just below the title") + description_short = fields.Html('Short Description', translate=True, help="The description that is displayed on the course card") description_html = fields.Html('Detailed Description', translate=tools.html_translate, sanitize_attributes=False, sanitize_form=False) channel_type = fields.Selection([ ('training', 'Training'), ('documentation', 'Documentation')], @@ -455,7 +456,7 @@ class Channel(models.Model): vals['channel_partner_ids'] = [(0, 0, { 'partner_id': self.env.user.partner_id.id })] - if vals.get('description') and not vals.get('description_short'): + if not is_html_empty(vals.get('description')) and is_html_empty(vals.get('description_short')): vals['description_short'] = vals['description'] channel = super(Channel, self.with_context(mail_create_nosubscribe=True)).create(vals) @@ -468,7 +469,7 @@ class Channel(models.Model): def write(self, vals): # If description_short wasn't manually modified, there is an implicit link between this field and description. - if vals.get('description') and not vals.get('description_short') and self.description == self.description_short: + if not is_html_empty(vals.get('description')) and is_html_empty(vals.get('description_short')) and self.description == self.description_short: vals['description_short'] = vals.get('description') res = super(Channel, self).write(vals) diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py index 8c8c3474bce..546ab68309b 100644 --- a/addons/website_slides/models/slide_slide.py +++ b/addons/website_slides/models/slide_slide.py @@ -18,7 +18,7 @@ from odoo.addons.http_routing.models.ir_http import slug from odoo.exceptions import Warning, UserError, AccessError from odoo.http import request from odoo.addons.http_routing.models.ir_http import url_for -from odoo.tools import sql +from odoo.tools import html2plaintext, sql class SlidePartnerRelation(models.Model): @@ -132,7 +132,7 @@ class Slide(models.Model): active = fields.Boolean(default=True, tracking=100) sequence = fields.Integer('Sequence', default=0) user_id = fields.Many2one('res.users', string='Uploaded by', default=lambda self: self.env.uid) - description = fields.Text('Description', translate=True) + description = fields.Html('Description', translate=True) channel_id = fields.Many2one('slide.channel', string="Course", required=True) tag_ids = fields.Many2many('slide.tag', 'rel_slide_tag', 'slide_id', 'tag_id', string='Tags') is_preview = fields.Boolean('Allow Preview', default=False, help="The course is accessible by anyone : the users don't need to join the channel to access the content of the course.") @@ -876,9 +876,9 @@ class Slide(models.Model): def _default_website_meta(self): res = super(Slide, self)._default_website_meta() res['default_opengraph']['og:title'] = res['default_twitter']['twitter:title'] = self.name - res['default_opengraph']['og:description'] = res['default_twitter']['twitter:description'] = self.description + res['default_opengraph']['og:description'] = res['default_twitter']['twitter:description'] = html2plaintext(self.description) res['default_opengraph']['og:image'] = res['default_twitter']['twitter:image'] = self.env['website'].image_url(self, 'image_1024') - res['default_meta_description'] = self.description + res['default_meta_description'] = html2plaintext(self.description) return res # --------------------------------------------------------- diff --git a/addons/website_slides/views/website_slides_templates_course.xml b/addons/website_slides/views/website_slides_templates_course.xml index 837455628c5..a2b40070242 100644 --- a/addons/website_slides/views/website_slides_templates_course.xml +++ b/addons/website_slides/views/website_slides_templates_course.xml @@ -130,7 +130,7 @@

-

+