From 38f15b4ed6305925a5638c97ce64ebdcd3decd90 Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Thu, 23 Jan 2020 14:04:49 +0100 Subject: [PATCH] [FIX] b_shift : email for non-attended shifts --- beesdoo_shift/data/mail_template.xml | 189 +++++++++++---------- beesdoo_shift/models/cooperative_status.py | 9 + 2 files changed, 107 insertions(+), 91 deletions(-) diff --git a/beesdoo_shift/data/mail_template.xml b/beesdoo_shift/data/mail_template.xml index eb72e0c..265bb55 100644 --- a/beesdoo_shift/data/mail_template.xml +++ b/beesdoo_shift/data/mail_template.xml @@ -1,94 +1,101 @@ - - - - - - Shift Non-attendance - Non-attendance to your last shift. - ${object.replaced_id.id or object.worker_id.id|safe} - - - ${object.worker_id.lang} - - - % if object.replaced_id: -

Hello ${object.replaced_id.name},

- -

You have been recorded as non-attended during your last shift (${format_tz(object.start_time,object.replaced_id.tz or 'Europe/Brussels','%d.%m.%Y - %H:%M')}). -

You were supposed to replace ${object.worker_id.name}.

- % endif - - % if object.worker_id: -

Hello ${object.worker_id.name},

- -

You have been recorded as non-attended during your last shift (${format_tz(object.start_time,object.worker_id.tz or 'Europe/Brussels','%d.%m.%Y - %H:%M')}). -

- % endif - - % if object.state == 'absent_0': - Super-cooperator assigned you 0 compensation, so you won't have any additionnal shift to do. - % endif - % if object.state == 'absent_1': - Super-cooperator assigned you 1 compensation, so you have to attend another shift. - % endif - % if object.state == 'absent_2': - Super-cooperator assigned you 2 compensations, so you have to attend 2 anothers shifts. - % endif - -

Your status have been updated to "${object.worker_id.state}". -

If you have any question regarding this non-attendance, just answer this e-mail. -

-
-

Cooperatively yours,
- The Members' office volunteers

-

${object.worker_id.company_id.name}.

- - % if object.worker_id.company_id.street: - ${object.worker_id.company_id.street} - % endif - % if object.worker_id.company_id.street2: - ${object.worker_id.company_id.street2}
- % endif - % if object.worker_id.company_id.city or object.worker_id.company_id.zip: - ${object.worker_id.company_id.zip} ${object.worker_id.company_id.city}
- % endif - % if object.worker_id.company_id.country_id: - ${object.worker_id.company_id.state_id and ('%s, ' % object.worker_id.company_id.state_id.name) or ''} ${object.worker_id.company_id.country_id.name or ''}
- % endif - % if object.worker_id.company_id.phone: - Phone:  ${object.worker_id.company_id.phone} - % endif - - % if object.worker_id.company_id.website: - - %endif - % if object.worker_id.company_id.logo_url: -
- -
- %endif - - ]]>
-
- - Non-validated sheet - [${object.day}] Non-validated sheet ${object.time_slot} - - - - -

${object.day} -

The attendance sheet for ${object.time_slot} is not validated. -

Please, do it as soon as possible so as to update workers' status. -

- - - ]]>
+ + + + + + Shift Non-attendance + Non-attendance to your last shift. + ${object.replaced_id.id or object.worker_id.id|safe} + + + ${object.worker_id.lang} + + + % if object.replaced_id: +

Hello ${object.replaced_id.name}, + +

You have been recorded as non-attended during your last shift (${format_tz(object.start_time,object.replaced_id.tz or 'Europe/Brussels','%d.%m.%Y - %H:%M')}), + and you were supposed to replace ${object.worker_id.name}. +

Your current status is "${object.worker_id.cooperative_status_ids.get_status_value()}". + % endif + + % if not object.replaced_id: +

Hello ${object.worker_id.name},

+ +

You have been recorded as non-attended during your last shift (${format_tz(object.start_time,object.worker_id.tz or 'Europe/Brussels','%d.%m.%Y - %H:%M')}). +

Your current status is "${object.worker_id.cooperative_status_ids.get_status_value()}". + % endif + + % if object.worker_id.working_mode == 'regular': + % if object.state == 'absent_0': +

Super-cooperator assigned you 0 compensation, so you won't have any additionnal shift to do before your next regular shift. + % endif + % if object.state == 'absent_1': +

Super-cooperator assigned you 1 compensation, so you have to attend one additionnal shift before your next regular shift. + % endif + % if object.state == 'absent_2': +

Super-cooperator assigned you 2 compensations, so you have to attend two additionnal shifts before your next regular shift. + % endif + % endif + + % if object.worker_id.working_mode == 'irregular': + Your shift counter is ${object.worker_id.cooperative_status_ids.sr}. + You should be at a minimum of 0 before the ${object.worker_id.cooperative_status_ids.future_alert_date}. + % endif + +
If you have any question regarding this non-attendance, just answer this e-mail. +

+
+

Cooperatively yours,
+ The Members' office volunteers

+

${object.worker_id.company_id.name}.

+ + % if object.worker_id.company_id.street: + ${object.worker_id.company_id.street} + % endif + % if object.worker_id.company_id.street2: + ${object.worker_id.company_id.street2}
+ % endif + % if object.worker_id.company_id.city or object.worker_id.company_id.zip: + ${object.worker_id.company_id.zip} ${object.worker_id.company_id.city}
+ % endif + % if object.worker_id.company_id.country_id: + ${object.worker_id.company_id.state_id and ('%s, ' % object.worker_id.company_id.state_id.name) or ''} ${object.worker_id.company_id.country_id.name or ''}
+ % endif + % if object.worker_id.company_id.phone: + Phone:  ${object.worker_id.company_id.phone} + % endif + + % if object.worker_id.company_id.website: + + %endif + % if object.worker_id.company_id.logo_url: +
+ +
+ %endif + + ]]>
+
+ + Non-validated sheet + [${object.day}] Non-validated sheet ${object.time_slot} + + + + +

${object.day} +

The attendance sheet for ${object.time_slot} is not validated. +

Please, do it as soon as possible so as to update workers' status. +

+ + + ]]>
Shift Summary diff --git a/beesdoo_shift/models/cooperative_status.py b/beesdoo_shift/models/cooperative_status.py index c0a2a53..9e6a142 100644 --- a/beesdoo_shift/models/cooperative_status.py +++ b/beesdoo_shift/models/cooperative_status.py @@ -36,6 +36,15 @@ class CooperativeStatus(models.Model): _rec_name = 'cooperator_id' _order = 'cooperator_id' + def get_status_value(self): + """ + Workararound to get translated selection value instead of key in mail template. + """ + + state_list = self.env["cooperative.status"]._fields["status"].selection + state_list = self.env["cooperative.status"]._fields['status']._description_selection(self.env) + + return dict(state_list)[self.status] today = fields.Date(help="Field that allow to compute field and store them even if they are based on the current date", default=fields.Date.today) cooperator_id = fields.Many2one('res.partner')