Skip to content

Commit

Permalink
[MIG] hr_holidays_credit: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraCForgeFlow committed Oct 8, 2024
1 parent d1cf77a commit 710496a
Show file tree
Hide file tree
Showing 14 changed files with 343 additions and 147 deletions.
10 changes: 5 additions & 5 deletions hr_holidays_credit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Leave Credit
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--holidays-lightgray.png?logo=github
:target: https://github.com/OCA/hr-holidays/tree/14.0/hr_holidays_credit
:target: https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_credit
:alt: OCA/hr-holidays
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/hr-holidays-14-0/hr-holidays-14-0-hr_holidays_credit
:target: https://translation.odoo-community.org/projects/hr-holidays-16-0/hr-holidays-16-0-hr_holidays_credit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-holidays&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand All @@ -42,7 +42,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-holidays/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr-holidays/issues/new?body=module:%20hr_holidays_credit%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/hr-holidays/issues/new?body=module:%20hr_holidays_credit%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Expand Down Expand Up @@ -79,6 +79,6 @@ 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.

This module is part of the `OCA/hr-holidays <https://github.com/OCA/hr-holidays/tree/14.0/hr_holidays_credit>`_ project on GitHub.
This module is part of the `OCA/hr-holidays <https://github.com/OCA/hr-holidays/tree/16.0/hr_holidays_credit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
7 changes: 5 additions & 2 deletions hr_holidays_credit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Leave Credit",
"version": "14.0.1.0.0",
"version": "16.0.1.0.0",
"category": "Human Resources",
"website": "https://github.com/OCA/hr-holidays",
"author": "CorporateHub, Odoo Community Association (OCA)",
Expand All @@ -13,5 +13,8 @@
"application": False,
"summary": "Enable negative leave balance for employees",
"depends": ["hr_holidays"],
"data": ["views/hr_leave_type.xml"],
"data": [
"views/hr_leave_type.xml",
"views/hr_leave_views.xml",
],
}
65 changes: 37 additions & 28 deletions hr_holidays_credit/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,48 @@ msgstr ""
"X-Generator: Weblate 4.17\n"

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid "%(name)s (%(extra)s)"
msgstr "%(name)s (%(extra)s)"
msgid " + credit"
msgstr " + crédito"

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid " available"
msgstr " disponibles"

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid " days"
msgstr " días"

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid "%g available"
msgstr "%g disponible"
msgid " hours"
msgstr " horas"

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid "%g available + credit"
msgstr "%g disponible + crédito"
msgid " used in credit"
msgstr " utilizados en crédito"

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid "%g used in credit"
msgstr "%g utilizado en el crédito"
msgid "%(name)s (%(extra)s)"
msgstr "%(name)s (%(extra)s)"

#. module: hr_holidays_credit
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_type__allow_credit
Expand All @@ -60,26 +80,14 @@ msgstr "Etiquetas de Empleado Acreditable"
msgid "Creditable Employees"
msgstr "Empleados Acreditados"

#. module: hr_holidays_credit
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave__display_name
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_type__display_name
msgid "Display Name"
msgstr "Mostrar Nombre"

#. module: hr_holidays_credit
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave__id
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_type__id
msgid "ID"
msgstr "ID"

#. module: hr_holidays_credit
#: model:ir.model.fields,help:hr_holidays_credit.field_hr_leave_type__allow_credit
msgid ""
"If set to true, employees would be able to make requests for this leave type"
" even if allocated amount is insufficient."
msgstr ""
"Si se establece en true, los empleados podrán solicitar este tipo de permiso "
"aunque la cantidad asignada sea insuficiente."
"Si se establece en true, los empleados podrán solicitar este tipo de permiso"
" aunque la cantidad asignada sea insuficiente."

#. module: hr_holidays_credit
#: model:ir.model.fields,help:hr_holidays_credit.field_hr_leave_type__creditable_department_ids
Expand All @@ -102,18 +110,19 @@ msgstr ""
msgid "If set, limits credit allowance to specified employees"
msgstr "Si se fija, limita la concesión de créditos a determinados empleados"

#. module: hr_holidays_credit
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave____last_update
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_type____last_update
msgid "Last Modified on"
msgstr "Última Modificación el"

#. module: hr_holidays_credit
#: model:ir.model,name:hr_holidays_credit.model_hr_leave
msgid "Time Off"
msgstr "Tiempo Libre"

#. module: hr_holidays_credit
#: model:ir.model,name:hr_holidays_credit.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr "Asignación de ausencias"

#. module: hr_holidays_credit
#: model:ir.model,name:hr_holidays_credit.model_hr_leave_type
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave__holiday_status_id
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_allocation__holiday_status_id
msgid "Time Off Type"
msgstr "Tipo de Tiempo Libre"
51 changes: 30 additions & 21 deletions hr_holidays_credit/i18n/hr_holidays_credit.pot
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,47 @@ msgstr ""
"Plural-Forms: \n"

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid "%(name)s (%(extra)s)"
msgid " + credit"
msgstr ""

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid " available"
msgstr ""

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid " days"
msgstr ""

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid "%g available"
msgid " hours"
msgstr ""

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid "%g available + credit"
msgid " used in credit"
msgstr ""

#. module: hr_holidays_credit
#. odoo-python
#: code:addons/hr_holidays_credit/models/hr_leave_type.py:0
#, python-format
msgid "%g used in credit"
msgid "%(name)s (%(extra)s)"
msgstr ""

#. module: hr_holidays_credit
Expand All @@ -57,18 +77,6 @@ msgstr ""
msgid "Creditable Employees"
msgstr ""

#. module: hr_holidays_credit
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave__display_name
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_type__display_name
msgid "Display Name"
msgstr ""

#. module: hr_holidays_credit
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave__id
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_type__id
msgid "ID"
msgstr ""

#. module: hr_holidays_credit
#: model:ir.model.fields,help:hr_holidays_credit.field_hr_leave_type__allow_credit
msgid ""
Expand All @@ -94,17 +102,18 @@ msgid "If set, limits credit allowance to specified employees"
msgstr ""

#. module: hr_holidays_credit
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave____last_update
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_type____last_update
msgid "Last Modified on"
#: model:ir.model,name:hr_holidays_credit.model_hr_leave
msgid "Time Off"
msgstr ""

#. module: hr_holidays_credit
#: model:ir.model,name:hr_holidays_credit.model_hr_leave
msgid "Time Off"
#: model:ir.model,name:hr_holidays_credit.model_hr_leave_allocation
msgid "Time Off Allocation"
msgstr ""

#. module: hr_holidays_credit
#: model:ir.model,name:hr_holidays_credit.model_hr_leave_type
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave__holiday_status_id
#: model:ir.model.fields,field_description:hr_holidays_credit.field_hr_leave_allocation__holiday_status_id
msgid "Time Off Type"
msgstr ""
1 change: 1 addition & 0 deletions hr_holidays_credit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import hr_leave_type
from . import hr_leave_allocation
from . import hr_leave
44 changes: 31 additions & 13 deletions hr_holidays_credit/models/hr_leave.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
# Copyright (C) 2018 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models
from odoo import api, fields, models


class HrLeave(models.Model):
_inherit = "hr.leave"

holiday_status_id = fields.Many2one(
domain=[
"|",
("has_valid_allocation", "=", True),
"|",
("requires_allocation", "=", "no"),
("allow_credit", "=", True),
]
)

@api.constrains("state", "number_of_days", "holiday_status_id")
def _check_holidays(self):
uncreditable_requests = self.filtered(
lambda holiday: not holiday._is_holiday_credit_allowed()
)
return super(HrLeave, uncreditable_requests)._check_holidays()

super(HrLeave, uncreditable_requests)._check_holidays()
def _check_overtime_deductible(self, leaves):
uncreditable_leaves = leaves.filtered(
lambda holiday: not holiday._is_holiday_credit_allowed()
)
return super()._check_overtime_deductible(uncreditable_leaves)

Check warning on line 31 in hr_holidays_credit/models/hr_leave.py

View check run for this annotation

Codecov / codecov/patch

hr_holidays_credit/models/hr_leave.py#L31

Added line #L31 was not covered by tests

def _is_holiday_credit_allowed(self):
self.ensure_one()

leave_type = self.holiday_status_id

if not leave_type.allow_credit:
return False

if self.employee_id in leave_type.creditable_employee_ids:
hr_leave_employees = set(self.employee_ids.ids)
hr_leave_type_employees = set(leave_type.creditable_employee_ids.ids)
same_employees = hr_leave_employees.issubset(hr_leave_type_employees)
if same_employees:
return True

if self.employee_id in (
leave_type.creditable_employee_category_ids.mapped("employee_ids")
):
hr_leave_type_cat_employees = set(
leave_type.creditable_employee_category_ids.mapped("employee_ids").ids
)
same_employees_cat = hr_leave_employees.issubset(hr_leave_type_cat_employees)
if same_employees_cat:
return True

Check warning on line 49 in hr_holidays_credit/models/hr_leave.py

View check run for this annotation

Codecov / codecov/patch

hr_holidays_credit/models/hr_leave.py#L49

Added line #L49 was not covered by tests

if self.employee_id in (
leave_type.creditable_department_ids.mapped("member_ids")
):
hr_leave_type_dpt_employees = set(
leave_type.creditable_department_ids.mapped("member_ids").ids
)
same_employees_dpt = hr_leave_employees.issubset(hr_leave_type_dpt_employees)
if same_employees_dpt:
return True

return (
Expand Down
17 changes: 17 additions & 0 deletions hr_holidays_credit/models/hr_leave_allocation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2018 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models
from odoo.osv import expression


class HolidaysAllocation(models.Model):
_inherit = "hr.leave.allocation"

def _domain_holiday_status_id(self):
res = super(HolidaysAllocation, self)._domain_holiday_status_id()
return expression.OR([[("allow_credit", "=", True)], res])

holiday_status_id = fields.Many2one(
"hr.leave.type", domain=_domain_holiday_status_id
)
Loading

0 comments on commit 710496a

Please sign in to comment.