From 9c5e4338fbd6ab3c450f4dca96a09740070d31ca Mon Sep 17 00:00:00 2001 From: qmo-odoo Date: Wed, 29 May 2019 10:46:19 +0000 Subject: [PATCH] [IMP] website_slides: Slide form view revamp This commit improves the user experience in the slide.slide form view by reorganizing fields, renaming fields and hiding unnecessary fields. This commit also introduces two new fields: - comment_count: computed field that gets the number of comments on the slide - channel_allow_comment: Related field to the channel_id.allow_coment. This field is used to hide/show unnecessary fields TaskID: 1978736 PR: #34232 --- addons/website_slides/models/slide_slide.py | 10 +++ .../views/slide_slide_views.xml | 88 +++++++++---------- 2 files changed, 54 insertions(+), 44 deletions(-) diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py index b7e0eb55495..4a0523e5593 100644 --- a/addons/website_slides/models/slide_slide.py +++ b/addons/website_slides/models/slide_slide.py @@ -152,11 +152,21 @@ class Slide(models.Model): slide_views = fields.Integer('# of Website Views', store=True, compute="_compute_slide_views") public_views = fields.Integer('# of Public Views') total_views = fields.Integer("Total # Views", default="0", compute='_compute_total', store=True) + # comments + comments_count = fields.Integer('Number of comments', compute="_compute_comments_count") + # channel + channel_type = fields.Selection(related="channel_id.channel_type", string="Channel type") + channel_allow_comment = fields.Boolean(related="channel_id.allow_comment", string="Allows comment") _sql_constraints = [ ('exclusion_html_content_and_url', "CHECK(html_content IS NULL OR url IS NULL)", "A slide is either filled with a document url or HTML content. Not both.") ] + @api.depends('website_message_ids.res_id', 'website_message_ids.model', 'website_message_ids.message_type') + def _compute_comments_count(self): + for slide in self: + slide.comments_count = len(slide.website_message_ids) + @api.depends('slide_views', 'public_views') def _compute_total(self): for record in self: diff --git a/addons/website_slides/views/slide_slide_views.xml b/addons/website_slides/views/slide_slide_views.xml index e6820b89fb6..9ee8fd67c98 100644 --- a/addons/website_slides/views/slide_slide_views.xml +++ b/addons/website_slides/views/slide_slide_views.xml @@ -52,54 +52,39 @@ />
-

- +

- - - - - - - - - - - - + - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - + - + + @@ -111,14 +96,14 @@ - + - + - - - - + + + + @@ -131,6 +116,21 @@ + + + + + + +
+ + + + + +
+
+