bemade_sports_clinic iteration 3 complete.
This commit is contained in:
parent
1a287d1452
commit
b19e71b0af
6 changed files with 107 additions and 25 deletions
|
|
@ -46,6 +46,7 @@
|
|||
'views/sports_clinic_menus.xml',
|
||||
'views/sports_patient_views.xml',
|
||||
'views/sports_clinic_portal_views.xml',
|
||||
'views/res_partner_views.xml',
|
||||
],
|
||||
'demo': ['data/demo/sports_clinic_demo_data.xml'],
|
||||
'installable': True,
|
||||
|
|
|
|||
|
|
@ -87,3 +87,19 @@ class TeamStaffPortal(CustomerPortal):
|
|||
'pager': pgr,
|
||||
'page_name': 'my_players',
|
||||
})
|
||||
|
||||
@http.route(route=['/my/players/<int:player_id>'], type='http', auth='user', website=True)
|
||||
def view_player(self, player_id, **kw):
|
||||
""" Display the active injuries for a given player. """
|
||||
player = http.request.env['sports.patient'].browse(player_id)
|
||||
if not player:
|
||||
raise UserError(_('This player could not be found.'))
|
||||
injuries = player.injury_ids.filtered(lambda r: r.stage == 'active')
|
||||
return http.request.render(
|
||||
template='bemade_sports_clinic.portal_my_player_injuries',
|
||||
qcontext={
|
||||
'player': player,
|
||||
'injuries': injuries,
|
||||
'page_name': 'my_player_injuries',
|
||||
}
|
||||
)
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
<field name="zip">H3C 3J7</field>
|
||||
<field name="phone">+1 (514) 343-6111</field>
|
||||
<field name="website">https://www.umontreal.ca</field>
|
||||
<field name="is_company" eval="True"/>
|
||||
</record>
|
||||
<record id="team_carabins" model="sports.team">
|
||||
<field name="name">Carabins (Football masculin)</field>
|
||||
|
|
@ -103,6 +104,7 @@
|
|||
<field name="country_id" ref="base.ca"/>
|
||||
<field name="zip">H3G 1M8</field>
|
||||
<field name="website">https://www.concordia.ca</field>
|
||||
<field name="is_company" eval="True"/>
|
||||
</record>
|
||||
<record id="team_stingers" model="sports.team">
|
||||
<field name="name">Stingers (Hockey masculin)</field>
|
||||
|
|
@ -156,6 +158,9 @@
|
|||
<field name="team_id" ref="team_stingers"/>
|
||||
<field name="role">head_coach</field>
|
||||
</record>
|
||||
<record id="base.partner_demo_portal" model="res.partner">
|
||||
<field name="parent_id" ref="partner_org_2"/>
|
||||
</record>
|
||||
<record id="carabins_trainer_user" model="res.users" context="{'no_reset_password': True}">
|
||||
<field name="partner_id" ref="partner_trainer_team_carabins"/>
|
||||
<field name="login">trainer</field>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ class Patient(models.Model):
|
|||
_name = 'sports.patient'
|
||||
_description = "Patient at a sports medicine clinic."
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_order = 'last_name, first_name'
|
||||
|
||||
first_name = fields.Char(required=True, tracking=True)
|
||||
last_name = fields.Char(required=True, tracking=True)
|
||||
|
|
@ -53,8 +54,13 @@ class Patient(models.Model):
|
|||
stage = fields.Selection(
|
||||
selection=[('no_play', 'Injured'), ('practice_ok', 'Cleared for Practice'), ('healthy', 'Cleared to Play')],
|
||||
compute='_compute_stage')
|
||||
|
||||
last_consultation_date = fields.Date()
|
||||
active_injury_count = fields.Integer(compute='_compute_active_injury_count')
|
||||
|
||||
@api.depends('injury_ids.stage')
|
||||
def _compute_active_injury_count(self):
|
||||
for rec in self:
|
||||
rec.active_injury_count = len(rec.injury_ids.filtered(lambda r: r.stage == 'active'))
|
||||
|
||||
@api.depends('match_status', 'practice_status')
|
||||
def _compute_stage(self):
|
||||
|
|
|
|||
15
bemade_sports_clinic/views/res_partner_views.xml
Normal file
15
bemade_sports_clinic/views/res_partner_views.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<record id="res_partner_view_form_sports_teams" model="ir.ui.view">
|
||||
<field name="name">res.partner.view.form.sports.teams</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<page name="contact_addresses" position="after">
|
||||
<page name="teams" attrs="{'invisible': [('owned_team_ids', '=', False)]}" string="Teams">
|
||||
<field name="owned_team_ids"/>
|
||||
</page>
|
||||
</page>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -51,33 +51,39 @@
|
|||
<t t-call="portal.portal_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Injured</th>
|
||||
<th>Injured Since</th>
|
||||
<th>Last Name</th>
|
||||
<th>First Name</th>
|
||||
<th>Active Injuries</th>
|
||||
<th>Match Status</th>
|
||||
<th>Practice Status</th>
|
||||
<th>Estimated Return Date</th>
|
||||
<th>Last Consultation Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="players" t-as="player">
|
||||
<tr>
|
||||
<t t-set="injured"
|
||||
t-value="'Yes' if player.is_injured else 'No'"/>
|
||||
<t t-set="stage" t-value="player.stage"/>
|
||||
<t t-set="url" t-value="'/my/players/' + str(player.id)"/>
|
||||
<tr t-attf-class="{{ ('text-danger' if stage == 'no_play'
|
||||
else 'text-warning') if stage != 'healthy'
|
||||
else '' }}">
|
||||
<td>
|
||||
<strong><span t-field="player.name"/></strong>
|
||||
<strong><a t-attf-href="{{ url }}" t-field="player.last_name"/></strong>
|
||||
</td>
|
||||
<td><span t-out="injured"/></td>
|
||||
<td>
|
||||
<span t-field="player.injured_since"
|
||||
t-options="{'widget': 'date'}"/>
|
||||
<strong><a t-attf-href="{{ url }}" t-field="player.first_name"/></strong>
|
||||
</td>
|
||||
<td><span t-field="player.active_injury_count"/></td>
|
||||
<td><span t-field="player.match_status"/></td>
|
||||
<td><span t-field="player.practice_status"/></td>
|
||||
<td>
|
||||
<span t-field="player.predicted_return_date"
|
||||
t-options="{'widget': 'date'}"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="player.last_consultation_date"
|
||||
t-options="{'widget': 'date'}"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
|
|
@ -90,25 +96,31 @@
|
|||
<t t-call="portal.portal_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>First Name</th>
|
||||
<th>Teams</th>
|
||||
<th>Injured</th>
|
||||
<th>Injured Since</th>
|
||||
<th>Active Injuries</th>
|
||||
<th>Match Status</th>
|
||||
<th>Practice Status</th>
|
||||
<th>Estimated Return Date</th>
|
||||
<th>Last Consultation Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="players" t-as="player">
|
||||
<tr>
|
||||
<t t-set="injured"
|
||||
t-value="'Yes' if player.is_injured else 'No'"/>
|
||||
<t t-set="stage" t-value="player.stage"/>
|
||||
<t t-set="url" t-value="'/my/players/' + str(player.id)"/>
|
||||
<tr t-attf-class="{{ ('text-danger' if stage == 'no_play'
|
||||
else 'text-warning') if stage != 'healthy'
|
||||
else '' }}">
|
||||
<td>
|
||||
<strong><span t-field="player.name"/></strong>
|
||||
<strong><a t-attf-href="{{ url }}" t-field="player.last_name"/></strong>
|
||||
</td>
|
||||
<td>
|
||||
<ul style="list-style-type: none;">
|
||||
<strong><a t-attf-href="{{ url }}" t-field="player.first_name"/></strong>
|
||||
</td>
|
||||
<td>
|
||||
<ul class="list-unstyled">
|
||||
<t t-foreach="player.team_ids" t-as="team">
|
||||
<li>
|
||||
<a t-attf-href="/my/team/{{ team.id }}"
|
||||
|
|
@ -117,17 +129,42 @@
|
|||
</t>
|
||||
</ul>
|
||||
</td>
|
||||
<td><span t-out="injured"/></td>
|
||||
<td>
|
||||
<span t-field="player.injured_since"
|
||||
t-options="{'widget': 'date'}"/>
|
||||
</td>
|
||||
<td><span t-field="player.active_injury_count"/></td>
|
||||
<td><span t-field="player.match_status"/></td>
|
||||
<td><span t-field="player.practice_status"/></td>
|
||||
<td>
|
||||
<span t-field="player.predicted_return_date"
|
||||
t-options="{'widget': 'date'}"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="player.last_consultation_date"
|
||||
t-options="{'widget': 'date'}"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
<template id="portal_my_player_injuries">
|
||||
<t t-call="portal.portal_layout">
|
||||
<h1>Injury Record for <span t-field="player.name"/></h1>
|
||||
<t t-call="portal.portal_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Active Injury</th>
|
||||
<th width="80%">Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<t t-foreach="injuries" t-as="injury">
|
||||
<tr>
|
||||
<td>
|
||||
<span t-field="injury.diagnosis"/>
|
||||
</td>
|
||||
<td>
|
||||
<span t-field="injury.external_notes"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
</tbody>
|
||||
|
|
@ -149,7 +186,9 @@
|
|||
t-attf-href="/my/players?{{ keep_query() }}">Players</a>
|
||||
<t t-else="">Players</t>
|
||||
</li>
|
||||
<li t-if="player" class="breadcrumb-item active" t-esc="player.name"/>
|
||||
<li t-if="player" class="breadcrumb-item active">
|
||||
<span t-field="player.name"/>
|
||||
</li>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
|
|
|
|||
Loading…
Reference in a new issue