Skip to content

Commit 64ae46a

Browse files
[IMP] hr_holidays_summary_email: pre-commit auto fixes
1 parent 2aa357d commit 64ae46a

11 files changed

Lines changed: 168 additions & 169 deletions

File tree

hr_holidays_summary_email/README.rst

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ Holidays Summary Email
1717
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1818
:alt: License: AGPL-3
1919
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--holidays-lightgray.png?logo=github
20-
:target: https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_summary_email
20+
:target: https://github.com/OCA/hr-holidays/tree/18.0/hr_holidays_summary_email
2121
:alt: OCA/hr-holidays
2222
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/hr-holidays-16-0/hr-holidays-16-0-hr_holidays_summary_email
23+
:target: https://translation.odoo-community.org/projects/hr-holidays-18-0/hr-holidays-18-0-hr_holidays_summary_email
2424
:alt: Translate me on Weblate
2525
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&target_branch=16.0
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&target_branch=18.0
2727
:alt: Try me on Runboat
2828

2929
|badge1| |badge2| |badge3| |badge4| |badge5|
3030

31-
This module allows sending a daily/weekly email to employees with a summary
32-
of the leaves on that period of other employees in the same company.
31+
This module allows sending a daily/weekly email to employees with a
32+
summary of the leaves on that period of other employees in the same
33+
company.
3334

3435
**Table of contents**
3536

@@ -39,43 +40,45 @@ of the leaves on that period of other employees in the same company.
3940
Usage
4041
=====
4142

42-
For each employee, three options can be selected for the Leave Summary Email
43-
configuration:
43+
For each employee, three options can be selected for the Leave Summary
44+
Email configuration:
4445

4546
- No: No email with the leaves summary is sent to the employee.
4647
- Daily: A daily email with the leaves summary is sent to the employee.
47-
- Weekly: A weekly email with the leaves summary is sent to the employee.
48+
- Weekly: A weekly email with the leaves summary is sent to the
49+
employee.
4850

49-
For the weekly email, the setting `Leave Weekly Summary Day of Week` allows
50-
setting the day of the week in which the email is sent.
51+
For the weekly email, the setting Leave Weekly Summary Day of Week
52+
allows setting the day of the week in which the email is sent.
5153

5254
Bug Tracker
5355
===========
5456

5557
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-holidays/issues>`_.
5658
In case of trouble, please check there if your issue has already been reported.
5759
If you spotted it first, help us to smash it by providing a detailed and welcomed
58-
`feedback <https://github.com/OCA/hr-holidays/issues/new?body=module:%20hr_holidays_summary_email%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
60+
`feedback <https://github.com/OCA/hr-holidays/issues/new?body=module:%20hr_holidays_summary_email%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
5961

6062
Do not contact contributors directly about support or help with technical issues.
6163

6264
Credits
6365
=======
6466

6567
Authors
66-
~~~~~~~
68+
-------
6769

6870
* ForgeFlow
6971

7072
Contributors
71-
~~~~~~~~~~~~
73+
------------
7274

73-
* ForgeFlow <http://www.forgeflow.com>
75+
- ForgeFlow
76+
<`http://www.forgeflow.com\\> <http://www.forgeflow.com\>>`__
7477

75-
* Jordi Masvidal
78+
- Jordi Masvidal
7679

7780
Maintainers
78-
~~~~~~~~~~~
81+
-----------
7982

8083
This module is maintained by the OCA.
8184

@@ -95,6 +98,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
9598

9699
|maintainer-JordiMForgeFlow|
97100

98-
This module is part of the `OCA/hr-holidays <https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_summary_email>`_ project on GitHub.
101+
This module is part of the `OCA/hr-holidays <https://github.com/OCA/hr-holidays/tree/18.0/hr_holidays_summary_email>`_ project on GitHub.
99102

100103
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 96 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,129 @@
11
<?xml version="1.0" ?>
22
<odoo noupdate="1">
3-
<record id="hr_holidays_summary_mail_template_daily" model="mail.template">
4-
<field name="name">Leaves Summary: Daily</field>
5-
<field name="model_id" ref="hr.model_hr_employee" />
6-
<field name="subject">Daily Leaves Summary</field>
7-
<field name="email_to">{{object.work_email}}</field>
8-
<field
3+
<record id="hr_holidays_summary_mail_template_daily" model="mail.template">
4+
<field name="name">Leaves Summary: Daily</field>
5+
<field name="model_id" ref="hr.model_hr_employee" />
6+
<field name="subject">Daily Leaves Summary</field>
7+
<field name="email_to">{{object.work_email}}</field>
8+
<field
99
name="email_from"
1010
>{{object.company_id.partner_id.email_formatted}}</field>
11-
<field name="body_html" type="html">
12-
<div style="margin: 0px; padding: 0px;">
13-
<p>Dear <t t-out="object.name" />,</p>
11+
<field name="body_html" type="html">
12+
<div style="margin: 0px; padding: 0px;">
13+
<p>Dear <t t-out="object.name" />,</p>
14+
<br />
15+
<t t-set="timeoffs" t-value="ctx.get('time_offs', [])" />
16+
<t t-if="timeoffs">
17+
<p>This is today's leave summary:</p>
1418
<br />
15-
<t t-set="timeoffs" t-value="ctx.get('time_offs', [])" />
16-
<t t-if="timeoffs">
17-
<p>This is today's leave summary:</p>
18-
<br />
19-
<table
19+
<table
2020
style="border-spacing: 0; border-collapse: collapse; width: 100%; text-align: center;"
2121
>
22-
<tr>
23-
<th
22+
<tr>
23+
<th
2424
style="padding: 5px; border: 1px solid black;"
2525
>Employee</th>
26-
<th
26+
<th
2727
style="padding: 5px; border: 1px solid black;"
2828
>Time Off</th>
29-
<th
30-
style="padding: 5px; border: 1px solid black;"
31-
>From</th>
32-
<th
33-
style="padding: 5px; border: 1px solid black;"
34-
>To</th>
35-
</tr>
36-
<t t-foreach="timeoffs" t-as="data">
37-
<t
29+
<th style="padding: 5px; border: 1px solid black;">From</th>
30+
<th style="padding: 5px; border: 1px solid black;">To</th>
31+
</tr>
32+
<t t-foreach="timeoffs" t-as="data">
33+
<t
3834
t-set="d_from"
3935
t-value="data.format_hr_leave_summary_date()"
4036
/>
41-
<t
37+
<t
4238
t-set="d_to"
4339
t-value="data.format_hr_leave_summary_date(False)"
4440
/>
45-
<tr>
46-
<td
47-
style="padding: 5px; border: 1px solid black;"
48-
><t t-out="data.employee_id.name" /></td>
49-
<td
50-
style="padding: 5px; border: 1px solid black;"
51-
><t t-out="data.name or ''" /></td>
52-
<td
53-
style="padding: 5px; border: 1px solid black;"
54-
><t t-out="d_from" /></td>
55-
<td
56-
style="padding: 5px; border: 1px solid black;"
57-
><t t-out="d_to" /></td>
58-
</tr>
59-
</t>
60-
</table></t>
61-
<t t-else=""><p>No leaves for today.</p></t>
62-
</div>
63-
</field>
64-
<field name="lang">{{object.lang}}</field>
65-
<field name="auto_delete" eval="True" />
66-
</record>
67-
<record id="hr_holidays_summary_mail_template_weekly" model="mail.template">
68-
<field name="name">Leaves Summary: Weekly</field>
69-
<field name="model_id" ref="hr.model_hr_employee" />
70-
<field name="subject">Weekly Leaves Summary</field>
71-
<field name="email_to">{{object.work_email}}</field>
72-
<field
41+
<tr>
42+
<td style="padding: 5px; border: 1px solid black;">
43+
<t t-out="data.employee_id.name" />
44+
</td>
45+
<td style="padding: 5px; border: 1px solid black;">
46+
<t t-out="data.name or ''" />
47+
</td>
48+
<td style="padding: 5px; border: 1px solid black;">
49+
<t t-out="d_from" />
50+
</td>
51+
<td style="padding: 5px; border: 1px solid black;">
52+
<t t-out="d_to" />
53+
</td>
54+
</tr>
55+
</t>
56+
</table>
57+
</t>
58+
<t t-else="">
59+
<p>No leaves for today.</p>
60+
</t>
61+
</div>
62+
</field>
63+
<field name="lang">{{object.lang}}</field>
64+
<field name="auto_delete" eval="True" />
65+
</record>
66+
<record id="hr_holidays_summary_mail_template_weekly" model="mail.template">
67+
<field name="name">Leaves Summary: Weekly</field>
68+
<field name="model_id" ref="hr.model_hr_employee" />
69+
<field name="subject">Weekly Leaves Summary</field>
70+
<field name="email_to">{{object.work_email}}</field>
71+
<field
7372
name="email_from"
7473
>{{object.company_id.partner_id.email_formatted}}</field>
75-
<field name="body_html" type="html">
76-
<div style="margin: 0px; padding: 0px;">
77-
<p>Dear <t t-out="object.name" />,</p>
74+
<field name="body_html" type="html">
75+
<div style="margin: 0px; padding: 0px;">
76+
<p>Dear <t t-out="object.name" />,</p>
77+
<br />
78+
<t t-set="timeoffs" t-value="ctx.get('time_offs', [])" />
79+
<t t-if="timeoffs">
80+
<p>This is the leaves summary for this week:</p>
7881
<br />
79-
<t t-set="timeoffs" t-value="ctx.get('time_offs', [])" />
80-
<t t-if="timeoffs">
81-
<p>This is the leaves summary for this week:</p>
82-
<br />
83-
<table
82+
<table
8483
style="border-spacing: 0; border-collapse: collapse; width: 100%; text-align: center;"
8584
>
86-
<tr>
87-
<th
85+
<tr>
86+
<th
8887
style="padding: 5px; border: 1px solid black;"
8988
>Employee</th>
90-
<th
89+
<th
9190
style="padding: 5px; border: 1px solid black;"
9291
>Time Off</th>
93-
<th
94-
style="padding: 5px; border: 1px solid black;"
95-
>From</th>
96-
<th
97-
style="padding: 5px; border: 1px solid black;"
98-
>To</th>
99-
</tr>
100-
<t t-foreach="timeoffs" t-as="data">
101-
<t
92+
<th style="padding: 5px; border: 1px solid black;">From</th>
93+
<th style="padding: 5px; border: 1px solid black;">To</th>
94+
</tr>
95+
<t t-foreach="timeoffs" t-as="data">
96+
<t
10297
t-set="d_from"
10398
t-value="data.format_hr_leave_summary_date()"
10499
/>
105-
<t
100+
<t
106101
t-set="d_to"
107102
t-value="data.format_hr_leave_summary_date(False)"
108103
/>
109-
<tr>
110-
<td
111-
style="padding: 5px; border: 1px solid black;"
112-
><t t-out="data.employee_id.name" /></td>
113-
<td
114-
style="padding: 5px; border: 1px solid black;"
115-
><t t-out="data.name or ''" /></td>
116-
<td
117-
style="padding: 5px; border: 1px solid black;"
118-
><t t-out="d_from" /></td>
119-
<td
120-
style="padding: 5px; border: 1px solid black;"
121-
><t t-out="d_to" /></td>
122-
</tr>
123-
</t>
124-
</table></t>
125-
<t t-else=""><p>No leaves for this week.</p></t>
126-
</div>
127-
</field>
128-
<field name="lang">{{object.lang}}</field>
129-
<field name="auto_delete" eval="True" />
130-
</record>
104+
<tr>
105+
<td style="padding: 5px; border: 1px solid black;">
106+
<t t-out="data.employee_id.name" />
107+
</td>
108+
<td style="padding: 5px; border: 1px solid black;">
109+
<t t-out="data.name or ''" />
110+
</td>
111+
<td style="padding: 5px; border: 1px solid black;">
112+
<t t-out="d_from" />
113+
</td>
114+
<td style="padding: 5px; border: 1px solid black;">
115+
<t t-out="d_to" />
116+
</td>
117+
</tr>
118+
</t>
119+
</table>
120+
</t>
121+
<t t-else="">
122+
<p>No leaves for this week.</p>
123+
</t>
124+
</div>
125+
</field>
126+
<field name="lang">{{object.lang}}</field>
127+
<field name="auto_delete" eval="True" />
128+
</record>
131129
</odoo>

hr_holidays_summary_email/models/hr_leave.py

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ class HrLeave(models.Model):
1313
@api.model
1414
def _get_hr_leave_summary_mail_template(self, summary_type):
1515
return self.env.ref(
16-
"hr_holidays_summary_email.hr_holidays_summary_mail_template_%s"
17-
% summary_type,
16+
f"hr_holidays_summary_email.hr_holidays_summary_mail_template_{summary_type}",
1817
raise_if_not_found=False,
1918
)
2019

@@ -93,12 +92,9 @@ def _cron_send_hr_leave_summary_emails(self):
9392
stype, company.id
9493
)
9594
employees_to_notify = self.env["hr.employee"].search(employee_domain)
96-
if employees_to_notify and hasattr(
97-
self, "_cron_send_hr_leave_summary_emails_%s" % stype
98-
):
99-
getattr(self, "_cron_send_hr_leave_summary_emails_%s" % stype)(
100-
employees_to_notify, company
101-
)
95+
method_name = f"_cron_send_hr_leave_summary_emails_{stype}"
96+
if employees_to_notify and hasattr(self, method_name):
97+
getattr(self, method_name)(employees_to_notify, company)
10298

10399
def format_hr_leave_summary_date(self, date_from=True):
104100
self.ensure_one()
@@ -107,31 +103,25 @@ def format_hr_leave_summary_date(self, date_from=True):
107103
else:
108104
res = self.date_to.strftime(DEFAULT_SERVER_DATE_FORMAT)
109105
if self.request_unit_half:
110-
res += (
111-
" %s"
112-
% dict(
113-
self.env["hr.leave"].fields_get(["request_date_from_period"])[
114-
"request_date_from_period"
115-
]["selection"]
116-
)[self.request_date_from_period]
106+
selection = dict(
107+
self.env["hr.leave"].fields_get(["request_date_from_period"])[
108+
"request_date_from_period"
109+
]["selection"]
117110
)
111+
res += f" {selection[self.request_date_from_period]}"
118112
elif self.request_unit_hours:
119113
if date_from:
120-
res += (
121-
" %s"
122-
% dict(
123-
self.env["hr.leave"].fields_get(["request_hour_from"])[
124-
"request_hour_from"
125-
]["selection"]
126-
)[self.request_hour_from]
114+
selection = dict(
115+
self.env["hr.leave"].fields_get(["request_hour_from"])[
116+
"request_hour_from"
117+
]["selection"]
127118
)
119+
res += f" {selection[self.request_hour_from]}"
128120
else:
129-
res += (
130-
" %s"
131-
% dict(
132-
self.env["hr.leave"].fields_get(["request_hour_to"])[
133-
"request_hour_to"
134-
]["selection"]
135-
)[self.request_hour_to]
121+
selection = dict(
122+
self.env["hr.leave"].fields_get(["request_hour_to"])[
123+
"request_hour_to"
124+
]["selection"]
136125
)
126+
res += f" {selection[self.request_hour_to]}"
137127
return res
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- ForgeFlow \<http://www.forgeflow.com\>
2+
3+
> - Jordi Masvidal

0 commit comments

Comments
 (0)