[IMP] website_slides: show relevant info while viewing partners' courses

Currently, when you click the stat button "x Courses" on a contact, you land
on the dashboard of the courses that this user follows. But this information
in not much useful here. You'd like to see information like progress of this
member for each courses, or when the member was last active on a specific
course.

With this commit, when you click the 'x Courses' stat button from a contact,
you will see the list view of model 'slide.channel.partner', having the
default filter for the contact from which you clicked the button. This will
show the additional and relevant information you need, and by removing the
filter, you'll be able to see info about all the attendees and their progress
on courses they follow (Note that here if the partner is a company, you
won't get default filter set but the records will be filtered by domain,
because we need to show courses of current contact and it's children, and
so we have to set domain in action, instead of adding default filter in
action context).

The same way, on the Attendees View of a course (when seeing attendees from the
course dashboard), we add 'Last Action' field, and instead of fixed domain, we
use filter to view attendees of a particular course, removing which can allow
us to view information about all the attendees from all courses.

We also introduce new 'Attendees' menu under 'eLearning > Reporting' that will
show information about all the attendees from all courses, with a default group
of channels

Task Id-2409447

closes odoo/odoo#64152

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Anjali
2021-05-17 09:12:26 +00:00
committed by Thibault Delavallée
parent 7a2b3362cb
commit d70af67954
5 changed files with 95 additions and 20 deletions
+10 -2
View File
@@ -57,7 +57,15 @@ class ResPartner(models.Model):
partner.slide_channel_company_count = 0
def action_view_courses(self):
action = self.env["ir.actions.actions"]._for_xml_id("website_slides.slide_channel_action_overview")
""" View partners courses. In singleton mode, return courses followed
by all its contacts (if company) or by himself (if not a company).
Otherwise simply set a domain on required partners. """
action = self.env["ir.actions.actions"]._for_xml_id("website_slides.slide_channel_partner_action")
action['name'] = _('Followed Courses')
action['domain'] = ['|', ('partner_ids', 'in', self.ids), ('partner_ids', 'in', self.child_ids.ids)]
if len(self) == 1 and self.is_company:
action['domain'] = [('partner_id', 'in', self.child_ids.ids)]
elif len(self) == 1:
action['context'] = {'search_default_partner_id': self.id}
else:
action['domain'] = [('partner_id', 'in', self.ids)]
return action
+16 -9
View File
@@ -26,6 +26,12 @@ class ChannelUsersRelation(models.Model):
completed_slides_count = fields.Integer('# Completed Slides')
partner_id = fields.Many2one('res.partner', index=True, required=True, ondelete='cascade')
partner_email = fields.Char(related='partner_id.email', readonly=True)
# channel-related information (for UX purpose)
channel_user_id = fields.Many2one('res.users', string='Responsible', related='channel_id.user_id')
channel_type = fields.Selection(related='channel_id.channel_type')
channel_visibility = fields.Selection(related='channel_id.visibility')
channel_enroll = fields.Selection(related='channel_id.enroll')
channel_website_id = fields.Many2one('website', string='Website', related='channel_id.website_id')
def _recompute_completion(self):
read_group_res = self.env['slide.slide.partner'].sudo().read_group(
@@ -517,21 +523,22 @@ class Channel(models.Model):
# Business / Actions
# ---------------------------------------------------------
def action_redirect_to_members(self, state=None):
def action_redirect_to_members(self, completed=False):
""" Redirects to attendees of the course. If completed is True, a filter
will be added in action that will display only attendees who have completed
the course. """
action = self.env["ir.actions.actions"]._for_xml_id("website_slides.slide_channel_partner_action")
action['domain'] = [('channel_id', 'in', self.ids)]
action_ctx = {'active_test': False}
if completed:
action_ctx['search_default_filter_completed'] = 1
if len(self) == 1:
action['display_name'] = _('Attendees of %s', self.name)
action['context'] = {'active_test': False, 'default_channel_id': self.id}
if state:
action['domain'] += [('completed', '=', state == 'completed')]
action_ctx['search_default_channel_id'] = self.id
action['context'] = action_ctx
return action
def action_redirect_to_running_members(self):
return self.action_redirect_to_members('running')
def action_redirect_to_done_members(self):
return self.action_redirect_to_members('completed')
return self.action_redirect_to_members(completed=True)
def action_channel_invite(self):
self.ensure_one()
@@ -9,6 +9,11 @@
<field name="partner_id"/>
<field name="partner_email"/>
<field name="channel_id"/>
<separator/>
<filter string="Completed" name="filter_completed" domain="[('completed', '=', True)]"/>
<group expand="0" string="Group By">
<filter string="Channel" name="groupby_channel_id" context="{'group_by': 'channel_id'}"/>
</group>
</search>
</field>
</record>
@@ -18,21 +23,71 @@
<field name="model">slide.channel.partner</field>
<field name="arch" type="xml">
<tree string="Attendees" editable="top">
<field name="create_date"/>
<field name="partner_id" string="Contact"/>
<field name="partner_email"/>
<field name="channel_id" string="Channel" invisible="context.get('default_channel_id',False)" />
<field name="completion" string="Progress" widget="progressbar" />
<field name="channel_id" string="Course Name"/>
<field name="channel_user_id"/>
<field name="partner_email" string="Email"/>
<field name="create_date" string="Enrolled On"/>
<field name="write_date" string="Last Action On"/>
<field name="completion" string="Progress" widget="progressbar"/>
<field name="channel_type" optional="hide"/>
<field name="channel_visibility" optional="hide"/>
<field name="channel_enroll" widget="badge"
decoration-success="channel_enroll == 'public'"
decoration-info="channel_enroll == 'invite'"
decoration-warning="channel_enroll == 'payment'"
optional="hide"/>
<field name="channel_website_id" groups="website.group_multi_website" optional="hide"/>
<button name="unlink" title="Remove" icon="fa-times" type="object"/>
</tree>
</field>
</record>
<record id="slide_channel_partner_view_kanban" model="ir.ui.view">
<field name="name">slide.channel.partner.view.kanban</field>
<field name="model">slide.channel.partner</field>
<field name="arch" type="xml">
<kanban string="Followed Courses">
<templates>
<t t-name="kanban-box">
<div t-attf-class="oe_kanban_color oe_kanban_card">
<div class="o_kanban_card_header">
<div class="o_kanban_card_header_title mb-3">
<strong class="o_kanban_record_title oe_partner_heading">
<field name="channel_id"/>
</strong>
<br/>
<field name="partner_id"/>
</div>
</div>
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_left">
<field name="completion" widget="progressbar"/>
</div>
<div class="oe_kanban_bottom_right">
<field name="channel_user_id" widget="many2one_avatar_user"/>
</div>
</div>
</div>
</t>
</templates>
</kanban>
</field>
</record>
<record id="slide_channel_partner_action" model="ir.actions.act_window">
<field name="name">Attendees</field>
<field name="res_model">slide.channel.partner</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">tree,form,kanban</field>
<field name="search_view_id" ref="website_slides.slide_channel_partner_view_search"/>
</record>
<record id="slide_channel_partner_action_report" model="ir.actions.act_window">
<field name="name">Attendees</field>
<field name="res_model">slide.channel.partner</field>
<field name="view_mode">tree,kanban</field>
<field name="search_view_id" ref="website_slides.slide_channel_partner_view_search"/>
<field name="context">{'search_default_groupby_channel': 1}</field>
</record>
</data>
</odoo>
@@ -50,15 +50,20 @@
parent="website_slides_menu_report"
sequence="2"
action="slide_slide_action_report"/>
<menuitem name="Attendees"
id="website_slides_menu_report_attendees"
parent="website_slides_menu_report"
sequence="5"
action="slide_channel_partner_action_report"/>
<menuitem name="Reviews"
id="website_slides_menu_report_reviews"
parent="website_slides_menu_report"
sequence="6"
sequence="10"
action="rating_rating_action_slide_channel_report"/>
<menuitem name="Quizzes"
id="website_slides_menu_report_quizzes"
parent="website_slides_menu_report"
sequence="7"
sequence="15"
action="slide_question_action_report"/>
<!-- Settings sub-menu -->
@@ -18,6 +18,6 @@
<menuitem name="Forum"
id="website_slides_menu_report_forum"
parent="website_slides.website_slides_menu_report"
sequence="8"
sequence="20"
action="forum_post_action_report"/>
</odoo>