Skip to content

Commit dd73a22

Browse files
Merge pull request #3 from Gerloav/16.0
Envio de correo y traducciones
2 parents e934e7e + ef2dec4 commit dd73a22

File tree

3 files changed

+78
-50
lines changed

3 files changed

+78
-50
lines changed

hr_workweek_reports/data/workweek_data.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
</thead>
9999
<tbody>
100100
<t
101-
t-foreach="request.env['hr.employee'].sudo().search([('resource_calendar_id', '=', calendar.id)])"
101+
t-foreach="ctx.get('employees_by_calendar').get(calendar.id, [])"
102102
t-as="employee"
103103
>
104104
<tr style="text-align: left;">

hr_workweek_reports/i18n/es.po

+70-48
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,17 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 16.0\n"
7+
"Project-Id-Version: Odoo Server 16.0+e\n"
88
"Report-Msgid-Bugs-To: \n"
9-
"POT-Creation-Date: 2024-02-05 13:18+0000\n"
10-
"PO-Revision-Date: 2024-02-05 13:18+0000\n"
9+
"POT-Creation-Date: 2024-12-16 09:15+0000\n"
10+
"PO-Revision-Date: 2024-12-16 09:15+0000\n"
1111
"Last-Translator: \n"
1212
"Language-Team: \n"
1313
"MIME-Version: 1.0\n"
1414
"Content-Type: text/plain; charset=UTF-8\n"
1515
"Content-Transfer-Encoding: \n"
1616
"Plural-Forms: \n"
1717

18-
#. module: hr_workweek_reports
19-
#: model:mail.template,subject:hr_workweek_reports.hours_worked_email_template
20-
msgid ""
21-
"\n"
22-
" {{object.name}}'s weekly report of worked hours: {{object.current_workweek.date_start}} -> {{object.current_workweek.date_end}}\n"
23-
" "
24-
msgstr ""
25-
"\n"
26-
" Informe semanal de las horas trabajadas de {{object.name}}: {{object.current_workweek.date_start}} -> {{object.current_workweek.date_end}}\n"
27-
" "
28-
2918
#. module: hr_workweek_reports
3019
#: model:mail.template,body_html:hr_workweek_reports.hours_worked_summary_email_template
3120
msgid ""
@@ -50,7 +39,7 @@ msgid ""
5039
" </tr>\n"
5140
" </thead>\n"
5241
" <tbody>\n"
53-
" <t t-foreach=\"request.env['hr.employee'].sudo().search([('resource_calendar_id', '=', calendar.id)])\" t-as=\"employee\">\n"
42+
" <t t-foreach=\"ctx.get('employees_by_calendar').get(calendar.id, [])\" t-as=\"employee\">\n"
5443
" <tr style=\"text-align: left;\">\n"
5544
" <td>\n"
5645
" <span t-field=\"employee.name\"></span>\n"
@@ -124,7 +113,7 @@ msgstr ""
124113
" </tr>\n"
125114
" </thead>\n"
126115
" <tbody>\n"
127-
" <t t-foreach=\"request.env['hr.employee'].sudo().search([('resource_calendar_id', '=', calendar.id)])\" t-as=\"employee\">\n"
116+
" <t t-foreach=\"ctx.get('employees_by_calendar').get(calendar.id, [])\" t-as=\"employee\">\n"
128117
" <tr style=\"text-align: left;\">\n"
129118
" <td>\n"
130119
" <span t-field=\"employee.name\"></span>\n"
@@ -180,41 +169,63 @@ msgstr ""
180169
#. module: hr_workweek_reports
181170
#: model:mail.template,body_html:hr_workweek_reports.hours_worked_email_template
182171
msgid ""
183-
"<p>Hello <t t-out=\"object.name\"/>,</p>\n"
184-
" <p>This week, from <t t-out=\"object.current_workweek.date_start\"/> to <t t-out=\"object.current_workweek.date_end\"/>,\n"
185-
" you have worked <t t-out=\"object.current_workweek.hours_worked\"/> hours of\n"
186-
" <t t-out=\"object.current_workweek.hours_to_work\"/></p>\n"
172+
"<t t-set=\"hours_difference\" t-value=\"ctx.get('hours_difference', hours_difference)\"></t>\n"
173+
" <t t-set=\"hours_difference_str\" t-value=\"ctx.get('hours_difference_str', hours_difference_str)\"></t>\n"
174+
" <t t-set=\"current_workweek_hours_to_work\" t-value=\"ctx.get('current_workweek_hours_to_work', current_workweek_hours_to_work)\"></t>\n"
175+
" <t t-set=\"current_workweek_hours_to_work_str\" t-value=\"ctx.get('current_workweek_hours_to_work_str', current_workweek_hours_to_work_str)\"></t>\n"
176+
" <t t-set=\"current_workweek_hours_worked_str\" t-value=\"ctx.get('current_workweek_hours_worked_str', current_workweek_hours_worked_str)\"></t>\n"
177+
" <p>Hello <t t-out=\"object.name\"></t>,</p>\n"
187178
"\n"
188-
" <p>Taking into account your past workweeks,\n"
189-
" <t t-if=\"object.hours_difference &gt; 0\">\n"
190-
" <span style=\"background-color: #ef9a9a\"> you still have to work <t t-out=\"abs(object.hours_difference)\"/> hours.</span>\n"
191-
" </t>\n"
192-
" <t t-elif=\"object.hours_difference &lt; 0\">\n"
193-
" <span style=\"background-color: #93c2e5\"> you have <t t-out=\"abs(object.hours_difference)\"/> hours of overtime work.</span>\n"
194-
" </t>\n"
195-
" <t t-else=\"\">\n"
196-
" <span style=\"background-color: #69f0ae\"> the difference between your worked and to work hours is <t t-out=\"abs(object.hours_difference)\"/>.</span>\n"
197-
" </t>\n"
198-
" </p>\n"
199-
" "
179+
" <p>This week, from <t t-out=\"object.current_workweek.date_start\"></t> to <t t-out=\"object.current_workweek.date_end\"></t>,\n"
180+
" you have worked <t t-out=\"current_workweek_hours_worked_str\"></t> hours of\n"
181+
" <t t-out=\"current_workweek_hours_to_work_str\"></t></p>\n"
182+
"\n"
183+
" <p>Taking into account your past workweeks,\n"
184+
" <t t-if=\"hours_difference &gt; 0\">\n"
185+
" <span style=\"background-color: #ef9a9a\"> you still have to work <t t-out=\"hours_difference_str\"></t> hours.</span>\n"
186+
" </t>\n"
187+
" <t t-elif=\"hours_difference &lt; 0\">\n"
188+
" <span style=\"background-color: #93c2e5\"> you have <t t-out=\"hours_difference_str\"></t> hours of overtime work.</span>\n"
189+
" </t>\n"
190+
" <t t-else=\"\">\n"
191+
" <span style=\"background-color: #69f0ae\"> the difference between your worked and to work hours is <t t-out=\"hours_difference_str\"></t>.</span>\n"
192+
" </t>\n"
193+
" </p>\n"
194+
" <p>\n"
195+
" <t t-if=\"object.imputable_daily_fail &gt; 0\">\n"
196+
" <span style=\"background-color: #ef9a9a\"> You have not imputed <t t-out=\"object.imputable_daily_fail\"></t> day(s) this week.</span>\n"
197+
" </t>\n"
198+
" </p>\n"
199+
" "
200200
msgstr ""
201-
"<p>Hola <t t-out=\"object.name\"/>,</p>\n"
202-
" <p>Esta semana, del <t t-out=\"object.current_workweek.date_start\"/> al <t t-out=\"object.current_workweek.date_end\"/>,\n"
203-
" has trabajado <t t-out=\"object.current_workweek.hours_worked\"/> de\n"
204-
" <t t-out=\"object.current_workweek.hours_to_work\"/></p> horas.\n"
201+
"<t t-set=\"hours_difference\" t-value=\"ctx.get('hours_difference', hours_difference)\"></t>\n"
202+
" <t t-set=\"hours_difference_str\" t-value=\"ctx.get('hours_difference_str', hours_difference_str)\"></t>\n"
203+
" <t t-set=\"current_workweek_hours_to_work\" t-value=\"ctx.get('current_workweek_hours_to_work', current_workweek_hours_to_work)\"></t>\n"
204+
" <t t-set=\"current_workweek_hours_to_work_str\" t-value=\"ctx.get('current_workweek_hours_to_work_str', current_workweek_hours_to_work_str)\"></t>\n"
205+
" <t t-set=\"current_workweek_hours_worked_str\" t-value=\"ctx.get('current_workweek_hours_worked_str', current_workweek_hours_worked_str)\"></t>\n"
206+
" <p>Hola <t t-out=\"object.name\"></t>,</p>\n"
205207
"\n"
206-
" <p>Teniendo en cuenta tus anteriores semanas de trabajo,\n"
207-
" <t t-if=\"object.hours_difference &gt; 0\">\n"
208-
" <span style=\"background-color: #ef9a9a\"> todavía tienes que recuperar <t t-out=\"abs(object.hours_difference)\"/> horas.</span>\n"
209-
" </t>\n"
210-
" <t t-elif=\"object.hours_difference &lt; 0\">\n"
211-
" <span style=\"background-color: #93c2e5\"> has hecho <t t-out=\"abs(object.hours_difference)\"/> horas extra.</span>\n"
212-
" </t>\n"
213-
" <t t-else=\"\">\n"
214-
" <span style=\"background-color: #69f0ae\"> la diferencia entre tus horas trabajadas y a trabajar es de <t t-out=\"abs(object.hours_difference)\"/> horas.</span>\n"
215-
" </t>\n"
216-
" </p>\n"
217-
" "
208+
" <p>Esta semana, desde el <t t-out=\"object.current_workweek.date_start\"></t> hasta el <t t-out=\"object.current_workweek.date_end\"></t>,\n"
209+
" has trabajado <t t-out=\"current_workweek_hours_worked_str\"></t> horas de\n"
210+
" <t t-out=\"current_workweek_hours_to_work_str\"></t></p>\n"
211+
"\n"
212+
" <p>Teniendo en cuenta tus semanas anteriores,\n"
213+
" <t t-if=\"hours_difference &gt; 0\">\n"
214+
" <span style=\"background-color: #ef9a9a\"> aún tienes que trabajar <t t-out=\"hours_difference_str\"></t> horas.</span>\n"
215+
" </t>\n"
216+
" <t t-elif=\"hours_difference &lt; 0\">\n"
217+
" <span style=\"background-color: #93c2e5\"> tienes <t t-out=\"hours_difference_str\"></t> horas de trabajo extra.</span>\n"
218+
" </t>\n"
219+
" <t t-else=\"\">\n"
220+
" <span style=\"background-color: #69f0ae\"> la diferencia entre las horas trabajadas y las horas que deberías trabajar es <t t-out=\"hours_difference_str\"></t>.</span>\n"
221+
" </t>\n"
222+
" </p>\n"
223+
" <p>\n"
224+
" <t t-if=\"object.imputable_daily_fail &gt; 0\">\n"
225+
" <span style=\"background-color: #ef9a9a\"> No has imputado <t t-out=\"object.imputable_daily_fail\"></t> dia(s) esta semana.</span>\n"
226+
" </t>\n"
227+
" </p>\n"
228+
" "
218229

219230
#. module: hr_workweek_reports
220231
#: model:ir.model,name:hr_workweek_reports.model_hr_employee
@@ -243,3 +254,14 @@ msgstr "Informe semanal de las horas trabajadas"
243254
#: model:mail.template,subject:hr_workweek_reports.hours_worked_summary_email_template
244255
msgid "Weekly summary report of worked hours"
245256
msgstr "Informe semanal de todas las horas trabajadas"
257+
258+
#. module: hr_workweek_reports
259+
#: model:mail.template,subject:hr_workweek_reports.hours_worked_email_template
260+
msgid ""
261+
"{{object.name}}'s weekly report of worked hours: "
262+
"{{object.current_workweek.date_start}} → "
263+
"{{object.current_workweek.date_end}}"
264+
msgstr ""
265+
"Informe semanal de las horas trabajadas de {{object.name}}: "
266+
"{{object.current_workweek.date_start}} -> "
267+
"{{object.current_workweek.date_end}}"

hr_workweek_reports/models/hr_employee.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ def send_weekly_summary_report_email(self):
4545
)
4646
]
4747
)
48+
employees_by_calendar = {
49+
calendar.id: self.env["hr.employee"].sudo().search(
50+
[("resource_calendar_id", "=", calendar.id)]
51+
)
52+
for calendar in allowed_calendars
53+
}
4854
allowed_employees = self.env["hr.employee"].search(
4955
[
5056
(
@@ -58,7 +64,7 @@ def send_weekly_summary_report_email(self):
5864
]
5965
)
6066
for allowed_employee in allowed_employees:
61-
template.with_context(calendars=allowed_calendars).send_mail(allowed_employee.id, force_send=True, email_values={
67+
template.with_context(calendars=allowed_calendars, employees_by_calendar=employees_by_calendar).send_mail(allowed_employee.id, force_send=True, email_values={
6268
'email_to': allowed_employee.work_email,
6369
'email_from': self.env["hr.employee"]
6470
.browse(

0 commit comments

Comments
 (0)