From f6f6ef1ef3716f48c5ca0171e0a537fa2e82f498 Mon Sep 17 00:00:00 2001 From: Marc Durepos Date: Tue, 17 Oct 2023 09:10:33 -0400 Subject: [PATCH] bemade_sports_clinic: Controller created along with basic homepage view to show counts for teams and patients to team staff. --- bemade_sports_clinic/__init__.py | 1 + bemade_sports_clinic/__manifest__.py | 3 +- bemade_sports_clinic/controllers/__init__.py | 1 + .../controllers/team_staff_portal.py | 31 +++++++++++++++++++ .../data/demo/sports_clinic_demo_data.xml | 3 +- .../views/sports_clinic_portal_views.xml | 19 ++++++++++++ 6 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 bemade_sports_clinic/controllers/__init__.py create mode 100644 bemade_sports_clinic/controllers/team_staff_portal.py create mode 100644 bemade_sports_clinic/views/sports_clinic_portal_views.xml diff --git a/bemade_sports_clinic/__init__.py b/bemade_sports_clinic/__init__.py index 0650744..f7209b1 100644 --- a/bemade_sports_clinic/__init__.py +++ b/bemade_sports_clinic/__init__.py @@ -1 +1,2 @@ from . import models +from . import controllers diff --git a/bemade_sports_clinic/__manifest__.py b/bemade_sports_clinic/__manifest__.py index 99eee77..c8ed6e3 100644 --- a/bemade_sports_clinic/__manifest__.py +++ b/bemade_sports_clinic/__manifest__.py @@ -37,7 +37,7 @@ 'author': 'Bemade Inc.', 'website': 'https://www.bemade.org', 'license': 'OPL-1', - 'depends': ['base', 'mail'], + 'depends': ['base', 'mail', 'portal'], 'data': [ 'security/sports_clinic_groups.xml', 'security/ir.model.access.csv', @@ -45,6 +45,7 @@ 'views/res_partner_views.xml', 'views/sports_clinic_menus.xml', 'views/patient_views.xml', + 'views/sports_clinic_portal_views.xml', ], 'demo': ['data/demo/sports_clinic_demo_data.xml'], 'installable': True, diff --git a/bemade_sports_clinic/controllers/__init__.py b/bemade_sports_clinic/controllers/__init__.py new file mode 100644 index 0000000..accb329 --- /dev/null +++ b/bemade_sports_clinic/controllers/__init__.py @@ -0,0 +1 @@ +from . import team_staff_portal diff --git a/bemade_sports_clinic/controllers/team_staff_portal.py b/bemade_sports_clinic/controllers/team_staff_portal.py new file mode 100644 index 0000000..6d4de72 --- /dev/null +++ b/bemade_sports_clinic/controllers/team_staff_portal.py @@ -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 + diff --git a/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml b/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml index 5c643a7..79a20ad 100644 --- a/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml +++ b/bemade_sports_clinic/data/demo/sports_clinic_demo_data.xml @@ -111,8 +111,9 @@ - + Coach + \ No newline at end of file diff --git a/bemade_sports_clinic/views/sports_clinic_portal_views.xml b/bemade_sports_clinic/views/sports_clinic_portal_views.xml new file mode 100644 index 0000000..866a679 --- /dev/null +++ b/bemade_sports_clinic/views/sports_clinic_portal_views.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file