[IMP] website_slides: improve content list view

This commit makes the content list view simpler, which now has following fields

  - name
  - channel_id
  - category_id (optional, default hidden)
  - user_id (with "many2one_avatar_user" widget)
  - is_published
  - date_published
  - completion_time (displays total and added float time widget)

Note that the view is now multi-edit, but we only want to update 'user_id' and
'is_published' fields in batch. So all other fields are readonly.

We have removed tracking from `date_published`, `website_published` field and
added tracking for `is_published` field. This information is sufficient.

TaskID-2607467

Part-of: odoo/odoo#76930
This commit is contained in:
ijas ahammed
2021-11-23 09:39:34 +00:00
committed by Thibault Delavallée
parent fb372a69de
commit ac3c4e6f67
2 changed files with 11 additions and 13 deletions
+3 -1
View File
@@ -160,7 +160,7 @@ class Slide(models.Model):
html_content = fields.Html("HTML Content", help="Custom HTML content for slides of type 'Web Page'.", translate=True, sanitize_attributes=False, sanitize_form=False)
# website
website_id = fields.Many2one(related='channel_id.website_id', readonly=True)
date_published = fields.Datetime('Publish Date', readonly=True, tracking=1)
date_published = fields.Datetime('Publish Date', readonly=True, tracking=False)
likes = fields.Integer('Likes', compute='_compute_user_info', store=True, compute_sudo=False)
dislikes = fields.Integer('Dislikes', compute='_compute_user_info', store=True, compute_sudo=False)
user_vote = fields.Integer('User vote', compute='_compute_user_info', compute_sudo=False)
@@ -183,6 +183,8 @@ class Slide(models.Model):
nbr_webpage = fields.Integer("Number of Webpages", compute='_compute_slides_statistics', store=True)
nbr_quiz = fields.Integer("Number of Quizs", compute="_compute_slides_statistics", store=True)
total_slides = fields.Integer(compute='_compute_slides_statistics', store=True)
is_published = fields.Boolean(tracking=1)
website_published = fields.Boolean(tracking=False)
_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.")
@@ -273,18 +273,14 @@
<field name="name">slide.slide.tree</field>
<field name="model">slide.slide</field>
<field name="arch" type="xml">
<tree string="Contents" sample="1">
<field name="name"/>
<field name="website_id" groups="website.group_multi_website"/>
<field name="active" invisible="1"/>
<field name="slide_type"/>
<field name="channel_id"/>
<field name="category_id"/>
<field name="date_published"/>
<field name="slide_views"/>
<field name="public_views"/>
<field name="total_views"/>
<field name="completion_time"/>
<tree string="Contents" sample="1" multi_edit="1">
<field name="name" readonly="1"/>
<field name="channel_id" readonly="1"/>
<field name="category_id" readonly="1" optional="hide"/>
<field name="user_id" widget="many2one_avatar_user"/>
<field name="is_published"/>
<field name="date_published" readonly="1"/>
<field name="completion_time" sum="Total" readonly="1" widget="float_time"/>
</tree>
</field>
</record>