Skip to content

Commit

Permalink
[ADD] resource_leaves_geographic
Browse files Browse the repository at this point in the history
  • Loading branch information
Shide committed Aug 1, 2024
1 parent 05881b1 commit 27fc1ff
Show file tree
Hide file tree
Showing 31 changed files with 1,068 additions and 75 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ addon | version | maintainers | summary
--- | --- | --- | ---
[hr_holidays_leave_auto_approve](hr_holidays_leave_auto_approve/) | 16.0.1.0.0 | | Leave type for auto-validation of Leaves
[hr_holidays_natural_period](hr_holidays_natural_period/) | 16.0.1.0.1 | [![victoralmau](https://github.com/victoralmau.png?size=30px)](https://github.com/victoralmau) | Apply natural days in holidays
[hr_holidays_public](hr_holidays_public/) | 16.0.2.0.2 | | Manage Public Holidays
[hr_holidays_public_city](hr_holidays_public_city/) | 16.0.2.0.1 | [![victoralmau](https://github.com/victoralmau.png?size=30px)](https://github.com/victoralmau) | HR Holidays Public City
[hr_holidays_public](hr_holidays_public/) | 16.0.2.0.1 | | Manage Public Holidays
[hr_holidays_public_city](hr_holidays_public_city/) | 16.0.2.0.0 | [![victoralmau](https://github.com/victoralmau.png?size=30px)](https://github.com/victoralmau) | HR Holidays Public City
[hr_leave_type_code](hr_leave_type_code/) | 16.0.1.0.0 | | Add a code field to HR Leaves

[//]: # (end addons)
Expand Down
2 changes: 1 addition & 1 deletion hr_holidays_public/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ HR Holidays Public
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:894f5c31a60d73d1c1c32f6ad3145570130ae938fb26150cadb170ef995ab8af
!! source digest: sha256:97a5473be95076d9cf3ac9f5ad936323cbd236f42e5a7ba2854bd41aeff163b8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion hr_holidays_public/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "HR Holidays Public",
"version": "16.0.2.0.2",
"version": "16.0.2.0.1",
"license": "AGPL-3",
"category": "Human Resources",
"author": "Michael Telahun Makonnen, "
Expand Down
11 changes: 2 additions & 9 deletions hr_holidays_public/models/hr_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ def _compute_number_of_hours_display(self):

def _get_domain_from_get_unusual_days(self, date_from, date_to=None):
domain = [("date", ">=", date_from)]
# Use the employee of the user or the one who has the context
employee_id = self.env.context.get("employee_id", False)
employee = (
self.env["hr.employee"].browse(employee_id)
if employee_id
else self.env.user.employee_id
)
if date_to:
domain.append(
(
Expand All @@ -70,7 +63,7 @@ def _get_domain_from_get_unusual_days(self, date_from, date_to=None):
date_to,
)
)
country_id = employee.address_id.country_id.id
country_id = self.env.user.employee_id.address_id.country_id.id
if not country_id:
country_id = self.env.company.country_id.id or False
if country_id:
Expand All @@ -81,7 +74,7 @@ def _get_domain_from_get_unusual_days(self, date_from, date_to=None):
("year_id.country_id", "=", country_id),
]
)
state_id = employee.address_id.state_id.id
state_id = self.env.user.employee_id.address_id.state_id.id
if not state_id:
state_id = self.env.company.state_id.id or False
if state_id:
Expand Down
13 changes: 5 additions & 8 deletions hr_holidays_public/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -367,7 +366,7 @@ <h1 class="title">HR Holidays Public</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:894f5c31a60d73d1c1c32f6ad3145570130ae938fb26150cadb170ef995ab8af
!! source digest: sha256:97a5473be95076d9cf3ac9f5ad936323cbd236f42e5a7ba2854bd41aeff163b8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_public"><img alt="OCA/hr-holidays" src="https://img.shields.io/badge/github-OCA%2Fhr--holidays-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-holidays-16-0/hr-holidays-16-0-hr_holidays_public"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module handles public holidays.</p>
Expand Down Expand Up @@ -493,9 +492,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
20 changes: 5 additions & 15 deletions hr_holidays_public/tests/test_holidays_public.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def setUpClass(cls):
cls.holiday_model_line = cls.env["hr.holidays.public.line"]
cls.employee_model = cls.env["hr.employee"]
cls.wizard_next_year = cls.env["public.holidays.next.year.wizard"]
cls.leave_model = cls.env["hr.leave"]

# Remove possibly existing public holidays that would interfer.
cls.holiday_model_line.search([]).unlink()
Expand Down Expand Up @@ -209,7 +208,8 @@ def assertPublicHolidayIsUnusualDay(
self, expected, country_id=None, state_ids=False
):
self.assertFalse(
self.leave_model.with_user(self.env.ref("base.user_demo").id)
self.env["hr.leave"]
.with_user(self.env.ref("base.user_demo").id)
.get_unusual_days("2019-07-01", date_to="2019-07-31")
.get("2019-07-30", False)
)
Expand All @@ -223,22 +223,12 @@ def assertPublicHolidayIsUnusualDay(
}
)
self.assertEqual(
self.leave_model.with_user(
self.env.ref("base.user_demo").id
).get_unusual_days("2019-07-01", date_to="2019-07-31")["2019-07-30"],
self.env["hr.leave"]
.with_user(self.env.ref("base.user_demo").id)
.get_unusual_days("2019-07-01", date_to="2019-07-31")["2019-07-30"],
expected,
)

def test_public_holidays_context(self):
self.env.ref("base.user_demo").employee_id.address_id.country_id = False
self.leave_model = self.leave_model.with_context(employee_id=self.employee.id)
self.assertPublicHolidayIsUnusualDay(
True,
country_id=self.env.ref(
"base.user_demo"
).employee_id.address_id.country_id.id,
)

def test_get_unusual_days_return_public_holidays_same_country(self):
self.env.ref("base.user_demo").employee_id.address_id.state_id = False
self.env.company.state_id = False
Expand Down
2 changes: 1 addition & 1 deletion hr_holidays_public_city/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ HR Holidays Public City
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f51266f14717ae02cc251ea6be1b8d5d865f7c811e295bf62cefbaa8072a6a81
!! source digest: sha256:556afea47f505328aa6542aac639bfaffe7cdafcc6c579d7397b34f63b26a0c4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion hr_holidays_public_city/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "HR Holidays Public City",
"version": "16.0.2.0.1",
"version": "16.0.2.0.0",
"category": "Tools",
"website": "https://github.com/OCA/hr-holidays",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
9 changes: 1 addition & 8 deletions hr_holidays_public_city/models/hr_leave.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ def _get_domain_from_get_unusual_days(self, date_from, date_to=None):
domain = super()._get_domain_from_get_unusual_days(
date_from=date_from, date_to=date_to
)
# Use the employee of the user or the one who has the context
employee_id = self.env.context.get("employee_id", False)
employee = (
self.env["hr.employee"].browse(employee_id)
if employee_id
else self.env.user.employee_id
)
# Add city domain
city_id = employee.address_id.city_id.id
city_id = self.env.user.employee_id.address_id.city_id.id
if not city_id:
city_id = self.env.company.partner_id.city_id.id or False
if city_id:
Expand Down
13 changes: 5 additions & 8 deletions hr_holidays_public_city/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +274,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: gray; } /* line numbers */
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +300,7 @@
span.pre {
white-space: pre }

span.problematic, pre.problematic {
span.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -367,7 +366,7 @@ <h1 class="title">HR Holidays Public City</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f51266f14717ae02cc251ea6be1b8d5d865f7c811e295bf62cefbaa8072a6a81
!! source digest: sha256:556afea47f505328aa6542aac639bfaffe7cdafcc6c579d7397b34f63b26a0c4
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_public_city"><img alt="OCA/hr-holidays" src="https://img.shields.io/badge/github-OCA%2Fhr--holidays-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-holidays-16-0/hr-holidays-16-0-hr_holidays_public_city"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds the cities at the public vacation line level as an extra discriminant.</p>
Expand Down Expand Up @@ -412,9 +411,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
Expand Down
26 changes: 5 additions & 21 deletions hr_holidays_public_city/tests/test_holidays_public.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def assertPublicHolidayIsUnusualDay(
self, expected, country_id=None, state_ids=False, city_ids=False
):
self.assertFalse(
self.leave_model.with_user(self.env.ref("base.user_demo").id)
self.env["hr.leave"]
.with_user(self.env.ref("base.user_demo").id)
.get_unusual_days("2019-07-01", date_to="2019-07-31")
.get("2019-07-30", False)
)
Expand All @@ -44,29 +45,12 @@ def assertPublicHolidayIsUnusualDay(
}
)
self.assertEqual(
self.leave_model.with_user(
self.env.ref("base.user_demo").id
).get_unusual_days("2019-07-01", date_to="2019-07-31")["2019-07-30"],
self.env["hr.leave"]
.with_user(self.env.ref("base.user_demo").id)
.get_unusual_days("2019-07-01", date_to="2019-07-31")["2019-07-30"],
expected,
)

def test_public_holidays_context(self):
self.env.ref("base.user_demo").employee_id.address_id.country_id = False
self.env.ref("base.user_demo").employee_id.address_id.state_id = False
self.env.ref("base.user_demo").employee_id.address_id.city_id = False
self.employee.address_id.country_id = self.env.ref("base.us")
self.employee.address_id.state_id = self.env.ref("base.state_us_4")
self.employee.address_id.city_id = self.us_city_a
self.leave_model = self.leave_model.with_context(employee_id=self.employee.id)
self.assertPublicHolidayIsUnusualDay(
True,
country_id=self.env.ref(
"base.user_demo"
).employee_id.address_id.country_id.id,
state_ids=[(6, 0, [self.employee.address_id.state_id.id])],
city_ids=[(6, 0, [self.employee.address_id.city_id.id])],
)

def test_get_unusual_days_return_public_holidays_same_state_same_city(self):
demo_user_empl_addr = self.env.ref("base.user_demo").employee_id.address_id
demo_user_empl_addr.country_id = self.env.ref("base.us")
Expand Down
Loading

0 comments on commit 27fc1ff

Please sign in to comment.