diff --git a/bemade_sports_clinic/data/sports_clinic_data.xml b/bemade_sports_clinic/data/sports_clinic_data.xml
index ce38047..2f3edc5 100644
--- a/bemade_sports_clinic/data/sports_clinic_data.xml
+++ b/bemade_sports_clinic/data/sports_clinic_data.xml
@@ -79,7 +79,7 @@
diff --git a/bemade_sports_clinic/migrations/16.0.1.5.7/post-migrate.py b/bemade_sports_clinic/migrations/16.0.1.5.7/post-migrate.py
index df76a53..63f51c0 100644
--- a/bemade_sports_clinic/migrations/16.0.1.5.7/post-migrate.py
+++ b/bemade_sports_clinic/migrations/16.0.1.5.7/post-migrate.py
@@ -9,14 +9,14 @@ def migrate(cr, version):
injury_followers = env['mail.followers'].search([('res_model', '=',
'sports.patient.injury')])
for f in patient_followers:
- if f.partner_id.user_id.has_group('base.group_user'):
+ if f.partner_id.user_ids.has_group('base.group_user'):
subtype = env.ref('bemade_sports_clinic.subtype_patient_internal_update').id
else:
subtype = env.ref('bemade_sports_clinic.subtype_patient_external_update').id
- f.write({'subtype_ids': [Command.set([subtype])]})
+ f.write({'subtype_ids': [Command.link(subtype)]})
for f in injury_followers:
- if f.partner_id.user_id.has_group('base.group_user'):
+ if f.partner_id.user_ids.has_group('base.group_user'):
subtype = env.ref('bemade_sports_clinic.subtype_patient_injury_internal_update').id
else:
subtype = env.ref('bemade_sports_clinic.subtype_patient_injury_external_update').id
- f.write({'subtype_ids': [Command.set([subtype])]})
+ f.write({'subtype_ids': [Command.link(subtype)]})
diff --git a/bemade_sports_clinic/models/patient.py b/bemade_sports_clinic/models/patient.py
index 93e98de..f2296eb 100644
--- a/bemade_sports_clinic/models/patient.py
+++ b/bemade_sports_clinic/models/patient.py
@@ -227,39 +227,27 @@ class Patient(models.Model):
raise_exception=False
)
- @api.model
- def __get_track_internal_external(self, params: Set[str]) -> Tuple[bool, bool]:
- """ Based on the fields being changed, determine if the notification being sent is meant for external
- or internal followers, or neither."""
- external = bool(external_tracking_fields & params)
- internal = external or bool(internal_tracking_fields & params)
- return external, internal
-
def _track_subtype(self, init_values):
- external, internal = self.__get_track_internal_external({key for key in init_values.keys()})
-
- if external:
- return self.env.ref('bemade_sports_clinic.subtype_patient_external_update')
- elif internal:
- return self.env.ref('bemade_sports_clinic.subtype_patient_internal_update')
- else:
- return self.env.ref('mail.mt_note')
+ return self.env.ref('mail.mt_note')
def _track_template(self, changes):
res = super()._track_template(changes)
- external, internal = self.__get_track_internal_external({change for change in changes})
+ params = set(changes)
+ external = bool(external_tracking_fields & params)
if external:
- first_external_field = (external_tracking_fields & set(changes)).pop()
+ first_external_field = (external_tracking_fields & params).pop()
res[first_external_field] = (
self.env.ref('bemade_sports_clinic.mail_template_patient_status_update'), {
'auto_delete_message': False,
+ 'subtype_id': self.env.ref('bemade_sports_clinic.subtype_patient_external_update').id,
'email_layout_xmlid': 'mail.mail_notification_light',
}
)
- if 'internal_notes' in changes:
+ if 'team_info_notes' in changes:
res['team_info_notes'] = (
self.env.ref('bemade_sports_clinic.mail_template_patient_new_internal_note'), {
'auto_delete_message': False,
+ 'subtype_id': self.env.ref('bemade_sports_clinic.subtype_patient_internal_update').id,
'email_layout_xmlid': 'mail.mail_notification_light',
}
)
diff --git a/bemade_sports_clinic/models/patient_injury.py b/bemade_sports_clinic/models/patient_injury.py
index c760dc1..f3c20c5 100644
--- a/bemade_sports_clinic/models/patient_injury.py
+++ b/bemade_sports_clinic/models/patient_injury.py
@@ -126,32 +126,19 @@ class PatientInjury(models.Model):
'context': self._context,
}
- @api.model
- def __get_track_internal_external(self, params: Set[str]) -> Tuple[bool, bool]:
- """ Based on the fields being changed, determine if the notification being sent is meant for external
- or internal followers, or neither."""
- external = bool(external_tracking_fields & params)
- internal = external or bool(internal_tracking_fields & params)
- return external, internal
-
def _track_subtype(self, init_values):
- external, internal = self.__get_track_internal_external({key for key in init_values.keys()})
-
- if external:
- return self.env.ref('bemade_sports_clinic.subtype_patient_injury_external_update')
- elif internal:
- return self.env.ref('bemade_sports_clinic.subtype_patient_injury_internal_update')
- else:
- return self.env.ref('mail.mt_note')
+ return self.env.ref('mail.mt_note')
def _track_template(self, changes):
res = super()._track_template(changes)
- external, internal = self.__get_track_internal_external({change for change in changes})
+ params = set(changes)
+ external = bool(external_tracking_fields & params)
if external:
- first_external_field = (external_tracking_fields & set(changes)).pop()
+ first_external_field = (external_tracking_fields & params).pop()
res[first_external_field] = (
self.env.ref('bemade_sports_clinic.mail_template_patient_injury_status_update'), {
'auto_delete_message': False,
+ 'subtype_id': self.env.ref('bemade_sports_clinic.subtype_patient_injury_external_update').id,
'email_layout_xmlid': 'mail.mail_notification_light',
}
)
@@ -159,6 +146,7 @@ class PatientInjury(models.Model):
res['internal_notes'] = (
self.env.ref('bemade_sports_clinic.mail_template_patient_injury_new_internal_note'), {
'auto_delete_message': False,
+ 'subtype_id': self.env.ref('bemade_sports_clinic.subtype_patient_injury_internal_update').id,
'email_layout_xmlid': 'mail.mail_notification_light',
}
)