bemade_sports_clinic: good to go for new version with split notifications (tested with staging)
This commit is contained in:
parent
ae385ed1f7
commit
a13d03f777
4 changed files with 18 additions and 42 deletions
|
|
@ -79,7 +79,7 @@
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<p><strong>New Note: </strong></p>
|
<p><strong>New Note: </strong></p>
|
||||||
<div><t t-out="object.note"/></div>
|
<div><t t-out="object.team_info_notes"/></div>
|
||||||
</div>
|
</div>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,14 @@ def migrate(cr, version):
|
||||||
injury_followers = env['mail.followers'].search([('res_model', '=',
|
injury_followers = env['mail.followers'].search([('res_model', '=',
|
||||||
'sports.patient.injury')])
|
'sports.patient.injury')])
|
||||||
for f in patient_followers:
|
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
|
subtype = env.ref('bemade_sports_clinic.subtype_patient_internal_update').id
|
||||||
else:
|
else:
|
||||||
subtype = env.ref('bemade_sports_clinic.subtype_patient_external_update').id
|
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:
|
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
|
subtype = env.ref('bemade_sports_clinic.subtype_patient_injury_internal_update').id
|
||||||
else:
|
else:
|
||||||
subtype = env.ref('bemade_sports_clinic.subtype_patient_injury_external_update').id
|
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)]})
|
||||||
|
|
|
||||||
|
|
@ -227,39 +227,27 @@ class Patient(models.Model):
|
||||||
raise_exception=False
|
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):
|
def _track_subtype(self, init_values):
|
||||||
external, internal = self.__get_track_internal_external({key for key in init_values.keys()})
|
return self.env.ref('mail.mt_note')
|
||||||
|
|
||||||
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')
|
|
||||||
|
|
||||||
def _track_template(self, changes):
|
def _track_template(self, changes):
|
||||||
res = super()._track_template(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:
|
if external:
|
||||||
first_external_field = (external_tracking_fields & set(changes)).pop()
|
first_external_field = (external_tracking_fields & params).pop()
|
||||||
res[first_external_field] = (
|
res[first_external_field] = (
|
||||||
self.env.ref('bemade_sports_clinic.mail_template_patient_status_update'), {
|
self.env.ref('bemade_sports_clinic.mail_template_patient_status_update'), {
|
||||||
'auto_delete_message': False,
|
'auto_delete_message': False,
|
||||||
|
'subtype_id': self.env.ref('bemade_sports_clinic.subtype_patient_external_update').id,
|
||||||
'email_layout_xmlid': 'mail.mail_notification_light',
|
'email_layout_xmlid': 'mail.mail_notification_light',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if 'internal_notes' in changes:
|
if 'team_info_notes' in changes:
|
||||||
res['team_info_notes'] = (
|
res['team_info_notes'] = (
|
||||||
self.env.ref('bemade_sports_clinic.mail_template_patient_new_internal_note'), {
|
self.env.ref('bemade_sports_clinic.mail_template_patient_new_internal_note'), {
|
||||||
'auto_delete_message': False,
|
'auto_delete_message': False,
|
||||||
|
'subtype_id': self.env.ref('bemade_sports_clinic.subtype_patient_internal_update').id,
|
||||||
'email_layout_xmlid': 'mail.mail_notification_light',
|
'email_layout_xmlid': 'mail.mail_notification_light',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -126,32 +126,19 @@ class PatientInjury(models.Model):
|
||||||
'context': self._context,
|
'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):
|
def _track_subtype(self, init_values):
|
||||||
external, internal = self.__get_track_internal_external({key for key in init_values.keys()})
|
return self.env.ref('mail.mt_note')
|
||||||
|
|
||||||
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')
|
|
||||||
|
|
||||||
def _track_template(self, changes):
|
def _track_template(self, changes):
|
||||||
res = super()._track_template(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:
|
if external:
|
||||||
first_external_field = (external_tracking_fields & set(changes)).pop()
|
first_external_field = (external_tracking_fields & params).pop()
|
||||||
res[first_external_field] = (
|
res[first_external_field] = (
|
||||||
self.env.ref('bemade_sports_clinic.mail_template_patient_injury_status_update'), {
|
self.env.ref('bemade_sports_clinic.mail_template_patient_injury_status_update'), {
|
||||||
'auto_delete_message': False,
|
'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',
|
'email_layout_xmlid': 'mail.mail_notification_light',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
@ -159,6 +146,7 @@ class PatientInjury(models.Model):
|
||||||
res['internal_notes'] = (
|
res['internal_notes'] = (
|
||||||
self.env.ref('bemade_sports_clinic.mail_template_patient_injury_new_internal_note'), {
|
self.env.ref('bemade_sports_clinic.mail_template_patient_injury_new_internal_note'), {
|
||||||
'auto_delete_message': False,
|
'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',
|
'email_layout_xmlid': 'mail.mail_notification_light',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue