Skip to content

Commit a044c80

Browse files
[IMP] hr_holidays_summary_email: pre-commit auto fixes
1 parent 8622f0c commit a044c80

11 files changed

Lines changed: 160 additions & 167 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: 88 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,111 @@
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>
14-
<br />
15-
<p>This is today's leave summary:</p>
16-
<br />
17-
<table
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+
<p>This is today's leave summary:</p>
16+
<br />
17+
<table
1818
style="border-spacing: 0; border-collapse: collapse; width: 100%; text-align: center;"
1919
>
20-
<tr>
21-
<th
22-
style="padding: 5px; border: 1px solid black;"
23-
>Employee</th>
24-
<th
25-
style="padding: 5px; border: 1px solid black;"
26-
>Time Off</th>
27-
<th style="padding: 5px; border: 1px solid black;">From</th>
28-
<th style="padding: 5px; border: 1px solid black;">To</th>
29-
</tr>
30-
<t t-set="timeoffs" t-value="ctx.get('time_offs', [])" />
31-
<t t-foreach="timeoffs" t-as="data">
32-
<t
20+
<tr>
21+
<th style="padding: 5px; border: 1px solid black;">Employee</th>
22+
<th style="padding: 5px; border: 1px solid black;">Time Off</th>
23+
<th style="padding: 5px; border: 1px solid black;">From</th>
24+
<th style="padding: 5px; border: 1px solid black;">To</th>
25+
</tr>
26+
<t t-set="timeoffs" t-value="ctx.get('time_offs', [])" />
27+
<t t-foreach="timeoffs" t-as="data">
28+
<t
3329
t-set="d_from"
3430
t-value="data.format_hr_leave_summary_date()"
3531
/>
36-
<t
32+
<t
3733
t-set="d_to"
3834
t-value="data.format_hr_leave_summary_date(False)"
3935
/>
40-
<tr>
41-
<td style="padding: 5px; border: 1px solid black;"><t
42-
t-out="data.employee_id.name"
43-
/></td>
44-
<td style="padding: 5px; border: 1px solid black;"><t
45-
t-out="data.name or ''"
46-
/></td>
47-
<td style="padding: 5px; border: 1px solid black;"><t
48-
t-out="d_from"
49-
/></td>
50-
<td style="padding: 5px; border: 1px solid black;"><t
51-
t-out="d_to"
52-
/></td>
53-
</tr>
54-
</t>
55-
</table>
56-
</div>
57-
</field>
58-
<field name="lang">{{object.lang}}</field>
59-
<field name="auto_delete" eval="True" />
60-
</record>
61-
<record id="hr_holidays_summary_mail_template_weekly" model="mail.template">
62-
<field name="name">Leaves Summary: Weekly</field>
63-
<field name="model_id" ref="hr.model_hr_employee" />
64-
<field name="subject">Weekly Leaves Summary</field>
65-
<field name="email_to">{{object.work_email}}</field>
66-
<field
36+
<tr>
37+
<td style="padding: 5px; border: 1px solid black;">
38+
<t t-out="data.employee_id.name" />
39+
</td>
40+
<td style="padding: 5px; border: 1px solid black;">
41+
<t t-out="data.name or ''" />
42+
</td>
43+
<td style="padding: 5px; border: 1px solid black;">
44+
<t t-out="d_from" />
45+
</td>
46+
<td style="padding: 5px; border: 1px solid black;">
47+
<t t-out="d_to" />
48+
</td>
49+
</tr>
50+
</t>
51+
</table>
52+
</div>
53+
</field>
54+
<field name="lang">{{object.lang}}</field>
55+
<field name="auto_delete" eval="True" />
56+
</record>
57+
<record id="hr_holidays_summary_mail_template_weekly" model="mail.template">
58+
<field name="name">Leaves Summary: Weekly</field>
59+
<field name="model_id" ref="hr.model_hr_employee" />
60+
<field name="subject">Weekly Leaves Summary</field>
61+
<field name="email_to">{{object.work_email}}</field>
62+
<field
6763
name="email_from"
6864
>{{object.company_id.partner_id.email_formatted}}</field>
69-
<field name="body_html" type="html">
70-
<div style="margin: 0px; padding: 0px;">
71-
<p>Dear <t t-out="object.name" />,</p>
72-
<br />
73-
<p>This is the leaves summary for this week:</p>
74-
<br />
75-
<table
65+
<field name="body_html" type="html">
66+
<div style="margin: 0px; padding: 0px;">
67+
<p>Dear <t t-out="object.name" />,</p>
68+
<br />
69+
<p>This is the leaves summary for this week:</p>
70+
<br />
71+
<table
7672
style="border-spacing: 0; border-collapse: collapse; width: 100%; text-align: center;"
7773
>
78-
<tr>
79-
<th
80-
style="padding: 5px; border: 1px solid black;"
81-
>Employee</th>
82-
<th
83-
style="padding: 5px; border: 1px solid black;"
84-
>Time Off</th>
85-
<th style="padding: 5px; border: 1px solid black;">From</th>
86-
<th style="padding: 5px; border: 1px solid black;">To</th>
87-
</tr>
88-
<t t-set="timeoffs" t-value="ctx.get('time_offs', [])" />
89-
<t t-foreach="timeoffs" t-as="data">
90-
<t
74+
<tr>
75+
<th style="padding: 5px; border: 1px solid black;">Employee</th>
76+
<th style="padding: 5px; border: 1px solid black;">Time Off</th>
77+
<th style="padding: 5px; border: 1px solid black;">From</th>
78+
<th style="padding: 5px; border: 1px solid black;">To</th>
79+
</tr>
80+
<t t-set="timeoffs" t-value="ctx.get('time_offs', [])" />
81+
<t t-foreach="timeoffs" t-as="data">
82+
<t
9183
t-set="d_from"
9284
t-value="data.format_hr_leave_summary_date()"
9385
/>
94-
<t
86+
<t
9587
t-set="d_to"
9688
t-value="data.format_hr_leave_summary_date(False)"
9789
/>
98-
<tr>
99-
<td style="padding: 5px; border: 1px solid black;"><t
100-
t-out="data.employee_id.name"
101-
/></td>
102-
<td style="padding: 5px; border: 1px solid black;"><t
103-
t-out="data.name or ''"
104-
/></td>
105-
<td style="padding: 5px; border: 1px solid black;"><t
106-
t-out="d_from"
107-
/></td>
108-
<td style="padding: 5px; border: 1px solid black;"><t
109-
t-out="d_to"
110-
/></td>
111-
</tr>
112-
</t>
113-
</table>
114-
</div>
115-
</field>
116-
<field name="lang">{{object.lang}}</field>
117-
<field name="auto_delete" eval="True" />
118-
</record>
90+
<tr>
91+
<td style="padding: 5px; border: 1px solid black;">
92+
<t t-out="data.employee_id.name" />
93+
</td>
94+
<td style="padding: 5px; border: 1px solid black;">
95+
<t t-out="data.name or ''" />
96+
</td>
97+
<td style="padding: 5px; border: 1px solid black;">
98+
<t t-out="d_from" />
99+
</td>
100+
<td style="padding: 5px; border: 1px solid black;">
101+
<t t-out="d_to" />
102+
</td>
103+
</tr>
104+
</t>
105+
</table>
106+
</div>
107+
</field>
108+
<field name="lang">{{object.lang}}</field>
109+
<field name="auto_delete" eval="True" />
110+
</record>
119111
</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

hr_holidays_summary_email/readme/CONTRIBUTORS.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This module allows sending a daily/weekly email to employees with a
2+
summary of the leaves on that period of other employees in the same
3+
company.

hr_holidays_summary_email/readme/DESCRIPTION.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)