bemade_sports_clinic: Got rid of the treatment professional type for res_users.

This commit is contained in:
Marc Durepos 2023-10-16 16:38:47 -04:00
parent 5113c065ab
commit ada948b41d
5 changed files with 16 additions and 31 deletions

View file

@ -106,5 +106,5 @@ class PatientInjury(models.Model):
column2='treatment_pro_id',
string='Treatment Professionals',
domain=[
('type', '=', 'treatment_pro')], )
('user_ids', '!=', False)], )
predicted_return_date = fields.Date(tracking=True)

View file

@ -10,9 +10,7 @@ class Partner(models.Model):
column1='team_id',
column2='patient_id',
string='Players')
type = fields.Selection(selection_add=[('team', 'Sports Team'),
('treatment_pro', 'Treatment Professional'),
])
type = fields.Selection(selection_add=[('team', 'Sports Team'),])
staff_partner_ids = fields.Many2many(comodel_name='res.partner',
relation='sports_team_staff_partner_rel',
column1='team_id',
@ -25,14 +23,6 @@ class Partner(models.Model):
string='Teams')
def write(self, vals):
# Override to validate changes to the 'type' field
treatment_pros = self.filtered(lambda r: r.type == 'treatment_pro')
if treatment_pros and 'type' in vals and vals['type'] != 'treatment_pro':
injuries = self.env['sports.patient.injury'].search_count(
[('treatment_professional_ids', 'in', treatment_pros.ids)])
if injuries:
raise UserError(_('Partner type cannot be changed since this treatment '
'professional appears on a patient injury record.'))
teams = self.filtered(lambda r: r.type == 'team')
if teams and 'type' in vals and vals['type'] != 'team':
if teams.mapped('staff_partner_ids') or teams.mapped('patient_ids'):
@ -42,13 +32,6 @@ class Partner(models.Model):
return super().write(vals)
def unlink(self):
treatment_pros = self.filtered(lambda r: r.type == 'treatment_pro')
if treatment_pros:
injuries = self.env['sports.patient.injury'].search_count(
[('treatment_professional_ids', 'in', treatment_pros.ids)])
if injuries:
raise UserError(_('Treatment professional cannot be deleted since they '
'appears on a patient injury record.'))
teams = self.filtered(lambda r: r.type == 'team')
if teams:
if teams.mapped('staff_partner_ids') or teams.mapped('patient_ids'):

View file

@ -86,5 +86,17 @@
</form>
</field>
</record>
<record id="sports_patient_injury_view_tree" model="ir.ui.view">
<field name="name">sports.patient.injury.view.tree</field>
<field name="model">sports.patient.injury</field>
<field name="arch" type="xml">
<tree string="Patient Injury History">
<field name="injury_date_time" widget="datetime"/>
<field name="diagnosis"/>
<field name="predicted_return_date" widget="date"/>
<field name="treatment_professional_ids"/>
</tree>
</field>
</record>
</data>
</odoo>

View file

@ -13,4 +13,4 @@
</field>
</record>
</data>
</odoo>
</odoo>

View file

@ -19,12 +19,6 @@
<field name="res_model">sports.patient</field>
<field name="view_mode">list,kanban,form</field>
</record>
<record id="action_view_treatment_pros" model="ir.actions.act_window">
<field name="name">Treatment Professionals</field>
<field name="res_model">res.partner</field>
<field name="domain">[('type', '=', 'treatment_pro')]</field>
<field name="view_mode">list,kanban,form</field>
</record>
<menuitem id="sports_clinic_root"
web_icon="bemade_sports_clinic,static/description/icon.png"
name="Sports Clinic"
@ -46,10 +40,6 @@
groups="bemade_sports_clinic.group_sports_clinic_user"
action="action_view_patient"/>
</menuitem>
<menuitem id="sports_clinic_treatment_pros"
name="Treatment Professionals"
groups="bemade_sports_clinic.group_sports_clinic_user"
action="action_view_treatment_pros"/>
</menuitem>
</data>
</odoo>
</odoo>