- Add comprehensive tabbed player detail view with full parity to internal view - Implement four organized tabs: Injuries, Patient Info, Team Info, Emergency Contacts - Add prominent status card above tabs showing match/practice status and allergies - Add email field to emergency contacts model and forms - Fix QWeb template errors by replacing t-field date widgets with t-esc in td elements - Convert HTML fields to Text fields to resolve tracking compatibility issues - Maintain role-based access control throughout all tabs - Add missing fields: injured_since, active_injury_count for complete parity - Improve UI/UX with color-coded status badges and responsive design
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
from odoo import models, fields, api
|
|
from odoo.addons.phone_validation.tools import phone_validation
|
|
|
|
|
|
class PatientContact(models.Model):
|
|
_name = 'sports.patient.contact'
|
|
_description = "Emergency or other contacts for a patient."
|
|
|
|
@api.model
|
|
def _valid_field_parameter(self, field, name):
|
|
# Allow 'unaccent' parameter for fields
|
|
return name == 'unaccent' or super()._valid_field_parameter(field, name)
|
|
|
|
sequence = fields.Integer(required=True, default=0)
|
|
name = fields.Char(unaccent=True)
|
|
contact_type = fields.Selection(selection=[
|
|
('mother', 'Mother'),
|
|
('father', 'Father'),
|
|
('other', 'Other'),
|
|
], required=True)
|
|
mobile = fields.Char(unaccent=False)
|
|
email = fields.Char(string='Email')
|
|
patient_id = fields.Many2one(comodel_name='sports.patient', string='Patient')
|
|
|
|
@api.onchange('mobile')
|
|
def _onchange_mobile_validation(self):
|
|
if self.mobile:
|
|
self.mobile = self._phone_format(self.mobile, force_format="INTERNATIONAL")
|
|
|
|
def _phone_format(self, number, force_format='E164'):
|
|
country = self.patient_id.country_id or self.env.company.country_id
|
|
if not country or not number:
|
|
return number
|
|
return phone_validation.phone_format(
|
|
number,
|
|
country.code if country else None,
|
|
country.phone_code if country else None,
|
|
force_format=force_format,
|
|
raise_exception=False
|
|
)
|