bemade-addons/bemade_sports_clinic/models/res_users.py
Denis Durepos c0834eb327 [REF] bemade_sports_clinic: Remove injury models and simplify data model
- Removed models/injury_models.py and all its references
- Converted relational fields to character fields:
  - body_location_id → body_location
  - injury_type_id → injury_type
- Updated portal templates to use text inputs instead of dropdowns
- Updated controller code to process the new field formats
- Removed related access rights from security CSV
- Modified test files to accommodate the new structure

This refactoring simplifies the data model by removing unnecessary
classifications that were adding complexity without significant benefit.
The direct text fields maintain the same functionality while reducing
the database overhead and simplifying the UI.
2025-07-16 11:37:50 -04:00

34 lines
1.2 KiB
Python

from odoo import models, fields, api, _, Command
class User(models.Model):
_inherit = "res.users"
accessible_team_ids = fields.Many2many(
comodel_name="sports.team",
compute="_compute_accessible_team_ids",
inverse="_inverse_accessible_team_ids",
)
def _compute_accessible_team_ids(self):
for rec in self:
rec.accessible_team_ids = rec.partner_id.teams_served_ids
def _inverse_accessible_team_ids(self):
for rec in self:
removed_teams = rec.partner_id.teams_served_ids - rec.accessible_team_ids
added_teams = rec.accessible_team_ids - rec.partner_id.teams_served_ids
removed_teams = rec.partner_id.teams_served_ids.filtered(
lambda team: team in removed_teams
)
removed_teams.remove_access(self)
self.env["sports.team.staff"].create(
[
{
"team_id": team.id,
"partner_id": rec.partner_id.id,
"role": "other",
}
for team in added_teams
]
)