bemade_sports_clinic: Controller created along with basic homepage view to show counts for teams and patients to team staff.
This commit is contained in:
parent
ad0ba3b086
commit
f6f6ef1ef3
6 changed files with 56 additions and 2 deletions
|
|
@ -1 +1,2 @@
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import controllers
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
'author': 'Bemade Inc.',
|
'author': 'Bemade Inc.',
|
||||||
'website': 'https://www.bemade.org',
|
'website': 'https://www.bemade.org',
|
||||||
'license': 'OPL-1',
|
'license': 'OPL-1',
|
||||||
'depends': ['base', 'mail'],
|
'depends': ['base', 'mail', 'portal'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/sports_clinic_groups.xml',
|
'security/sports_clinic_groups.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
|
@ -45,6 +45,7 @@
|
||||||
'views/res_partner_views.xml',
|
'views/res_partner_views.xml',
|
||||||
'views/sports_clinic_menus.xml',
|
'views/sports_clinic_menus.xml',
|
||||||
'views/patient_views.xml',
|
'views/patient_views.xml',
|
||||||
|
'views/sports_clinic_portal_views.xml',
|
||||||
],
|
],
|
||||||
'demo': ['data/demo/sports_clinic_demo_data.xml'],
|
'demo': ['data/demo/sports_clinic_demo_data.xml'],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
|
|
||||||
1
bemade_sports_clinic/controllers/__init__.py
Normal file
1
bemade_sports_clinic/controllers/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from . import team_staff_portal
|
||||||
31
bemade_sports_clinic/controllers/team_staff_portal.py
Normal file
31
bemade_sports_clinic/controllers/team_staff_portal.py
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
from odoo.addons.portal.controllers.portal import CustomerPortal
|
||||||
|
from odoo import http
|
||||||
|
|
||||||
|
|
||||||
|
class TeamStaffPortal(CustomerPortal):
|
||||||
|
def _prepare_home_portal_values(self, counters):
|
||||||
|
rtn = super()._prepare_home_portal_values(counters)
|
||||||
|
teams_domain = self._prepare_teams_domain()
|
||||||
|
players_domain = self._prepare_players_domain(teams_domain)
|
||||||
|
rtn['teams_count'] = http.request.env['res.partner'].search_count(teams_domain)
|
||||||
|
rtn['players_count'] = http.request.env['sports.patient'].search_count(players_domain)
|
||||||
|
return rtn
|
||||||
|
|
||||||
|
def _prepare_teams_domain(self):
|
||||||
|
user = http.request.env.user
|
||||||
|
partner = http.request.env.user.partner_id
|
||||||
|
return [
|
||||||
|
('staff_partner_ids', 'in', partner.id),
|
||||||
|
('type', '=', 'team'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def _prepare_players_domain(self, teams_domain):
|
||||||
|
team_ids = http.request.env['res.partner'].search(teams_domain).ids
|
||||||
|
return [
|
||||||
|
('team_ids', 'in', team_ids),
|
||||||
|
]
|
||||||
|
|
||||||
|
# @http.route(route=['/my/teams'], type=http, auth='user', website=True)
|
||||||
|
# def view_teams(self, ):
|
||||||
|
# pass
|
||||||
|
|
||||||
|
|
@ -111,8 +111,9 @@
|
||||||
<field name="groups_id" eval="[Command.link(ref('group_sports_clinic_user'))]"/>
|
<field name="groups_id" eval="[Command.link(ref('group_sports_clinic_user'))]"/>
|
||||||
</record>
|
</record>
|
||||||
<record id="base.partner_demo_portal" model="res.partner">
|
<record id="base.partner_demo_portal" model="res.partner">
|
||||||
<field name="parent_id" ref="bemade_sports_clinic.team_carabins"/>
|
<field name="parent_id" ref="team_carabins"/>
|
||||||
<field name="function">Coach</field>
|
<field name="function">Coach</field>
|
||||||
|
<field name="staff_team_ids" eval="[Command.link(ref('team_carabins'))]"/>
|
||||||
</record>
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
19
bemade_sports_clinic/views/sports_clinic_portal_views.xml
Normal file
19
bemade_sports_clinic/views/sports_clinic_portal_views.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<template id="portal_my_home" inherit_id="portal.portal_my_home">
|
||||||
|
<xpath expr="//div[hasclass('o_portal_docs')]" position="inside">
|
||||||
|
<t t-call="portal.portal_docs_entry">
|
||||||
|
<t t-set="title">Teams</t>
|
||||||
|
<t t-set="url">/my/teams</t>
|
||||||
|
<t t-set="placeholder_count">teams_count</t>
|
||||||
|
</t>
|
||||||
|
<t t-call="portal.portal_docs_entry">
|
||||||
|
<t t-set="title">Players</t>
|
||||||
|
<t t-set="url">/my/players</t>
|
||||||
|
<t t-set="placeholder_count">players_count</t>
|
||||||
|
</t>
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in a new issue