Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] hr_employee_service #1243

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions hr_employee_service/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
===================
HR Employee Service
===================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
: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-lightgray.png?logo=github
:target: https://github.com/OCA/hr/tree/16.0/hr_employee_service
:alt: OCA/hr
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/hr-16-0/hr-16-0-hr_employee_service
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/116/16.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

With this module installed, HR Officer can keep records on employee hire,
start, and termination dates. This information is also used to automatically
calculate length of employee's service for the company.

*Hire Date* typically is the date when employee has accepted or signed the offer.

*Start Date* typically is the date of the first official work day since which employee is
entitled to receiving benefits and various accrual allocations.

*Termination Date* typically is the date of the last official work day since until which employee
is entitled to receiving benefits and various accrual allocations.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr/issues/new?body=module:%20hr_employee_service%0Aversion:%2015.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.

Credits
=======

Authors
~~~~~~~

* CorporateHub

Contributors
~~~~~~~~~~~~

* `CorporateHub <https://corporatehub.eu/>`__

* Alexey Pelykh <[email protected]>

* Saran Lim. <[email protected]>

* Nattapong W. <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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 <https://github.com/OCA/hr/tree/16.0/hr_employee_service>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions hr_employee_service/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
18 changes: 18 additions & 0 deletions hr_employee_service/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (C) 2018 Brainbean Apps (https://brainbeanapps.com)
# Copyright 2020 CorporateHub (https://corporatehub.eu)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "HR Employee Service",
"version": "16.0.1.0.0",
"category": "Human Resources",
"website": "https://github.com/OCA/hr",
"author": "CorporateHub, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"application": False,
"summary": "Employee service information & duration",
"depends": ["hr"],
"external_dependencies": {"python": ["dateutil", "mock"]},
"data": ["views/hr_employee.xml"],
}
102 changes: 102 additions & 0 deletions hr_employee_service/i18n/hr_employee_service.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_employee_service
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-06-05 11:33+0000\n"
"PO-Revision-Date: 2023-06-05 11:33+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_employee_service
#: model_terms:ir.ui.view,arch_db:hr_employee_service.view_employee_form_inherit_extension
msgid "<span> day(s)</span>"
msgstr ""

#. module: hr_employee_service
#: model_terms:ir.ui.view,arch_db:hr_employee_service.view_employee_form_inherit_extension
msgid "<span> month(s) </span>"
msgstr ""

#. module: hr_employee_service
#: model_terms:ir.ui.view,arch_db:hr_employee_service.view_employee_form_inherit_extension
msgid "<span> year(s) </span>"
msgstr ""

#. module: hr_employee_service
#: model:ir.model,name:hr_employee_service.model_hr_employee
msgid "Employee"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,field_description:hr_employee_service.field_hr_employee__service_hire_date
msgid "Hire Date"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,help:hr_employee_service.field_hr_employee__service_hire_date
msgid ""
"Hire date is normally the date an employee completes new hire paperwork"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,field_description:hr_employee_service.field_hr_employee__service_duration
#: model_terms:ir.ui.view,arch_db:hr_employee_service.view_employee_form_inherit_extension
msgid "Service Duration"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,field_description:hr_employee_service.field_hr_employee__service_duration_days
msgid "Service Duration (days)"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,field_description:hr_employee_service.field_hr_employee__service_duration_months
msgid "Service Duration (months)"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,field_description:hr_employee_service.field_hr_employee__service_duration_years
msgid "Service Duration (years)"
msgstr ""

#. module: hr_employee_service
#: model_terms:ir.ui.view,arch_db:hr_employee_service.view_employee_form_inherit_extension
msgid "Service Information"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,help:hr_employee_service.field_hr_employee__service_duration
msgid "Service duration in days"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,field_description:hr_employee_service.field_hr_employee__service_start_date
msgid "Start Date"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,help:hr_employee_service.field_hr_employee__service_start_date
msgid ""
"Start date is the first day the employee actually works and this date is "
"used for accrual leave allocations calculation"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,field_description:hr_employee_service.field_hr_employee__service_termination_date
msgid "Termination Date"
msgstr ""

#. module: hr_employee_service
#: model:ir.model.fields,help:hr_employee_service.field_hr_employee__service_termination_date
msgid ""
"Termination date is the last day the employee actually works and this date "
"is used for accrual leave allocations calculation"
msgstr ""
3 changes: 3 additions & 0 deletions hr_employee_service/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import hr_employee
119 changes: 119 additions & 0 deletions hr_employee_service/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Copyright (C) 2018-2019 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from datetime import timedelta
from math import fabs

from dateutil.relativedelta import relativedelta

from odoo import api, fields, models


class HrEmployee(models.Model):
_inherit = "hr.employee"

service_hire_date = fields.Date(
string="Hire Date",
groups="hr.group_hr_user",
tracking=True,
help=(
"Hire date is normally the date an employee completes new hire paperwork"
),
)
service_start_date = fields.Date(
string="Start Date",
groups="hr.group_hr_user",
tracking=True,
help=(
"Start date is the first day the employee actually works and"
" this date is used for accrual leave allocations calculation"
),
)
service_termination_date = fields.Date(
string="Termination Date",
related="departure_date",
help=(
"Termination date is the last day the employee actually works and"
" this date is used for accrual leave allocations calculation"
),
)
service_duration = fields.Integer(
groups="hr.group_hr_user",
readonly=True,
compute="_compute_service_duration",
help="Service duration in days",
)
service_duration_years = fields.Integer(
string="Service Duration (years)",
groups="hr.group_hr_user",
readonly=True,
compute="_compute_service_duration_display",
)
service_duration_months = fields.Integer(
string="Service Duration (months)",
groups="hr.group_hr_user",
readonly=True,
compute="_compute_service_duration_display",
)
service_duration_days = fields.Integer(
string="Service Duration (days)",
groups="hr.group_hr_user",
readonly=True,
compute="_compute_service_duration_display",
)

@api.depends("service_start_date", "service_termination_date")
def _compute_service_duration(self):
for record in self:
service_until = record.service_termination_date or fields.Date.today()
if record.service_start_date and service_until > record.service_start_date:
service_since = record.service_start_date
service_duration = fabs(
(service_until - service_since) / timedelta(days=1)
)
record.service_duration = int(service_duration)
else:
record.service_duration = 0

@api.depends("service_start_date", "service_termination_date")
def _compute_service_duration_display(self):
for record in self:
service_until = record.service_termination_date or fields.Date.today()
if record.service_start_date and service_until > record.service_start_date:
service_duration = relativedelta(
service_until, record.service_start_date
)
record.service_duration_years = service_duration.years
record.service_duration_months = service_duration.months
record.service_duration_days = service_duration.days
else:
record.service_duration_years = 0
record.service_duration_months = 0
record.service_duration_days = 0

@api.onchange("service_hire_date")
def _onchange_service_hire_date(self):
if not self.service_start_date:
self.service_start_date = self.service_hire_date

# NOTE: Support odoo/odoo@90731ad170c503cdfe89a9998fa1d1e2a5035c86
def _get_date_start_work(self):
return self.sudo().service_start_date or super()._get_date_start_work()

def get_service_duration_from_date(self, date=None):
"""
Returns the employee service duration for the given date.
This function is used in OCA/payroll modules as a helper function
to calculate employee service duration calculated for the given date.
"""
self.ensure_one()
if date and self.service_start_date and date > self.service_start_date:
service_duration = relativedelta(date, self.service_start_date)
res = {
"years": service_duration.years,
"months": service_duration.months,
"days": service_duration.days,
}
else:
res = {"years": 0, "months": 0, "days": 0}
return res
7 changes: 7 additions & 0 deletions hr_employee_service/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
* `CorporateHub <https://corporatehub.eu/>`__

* Alexey Pelykh <[email protected]>

* Saran Lim. <[email protected]>

* Nattapong W. <[email protected]>
11 changes: 11 additions & 0 deletions hr_employee_service/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
With this module installed, HR Officer can keep records on employee hire,
start, and termination dates. This information is also used to automatically
calculate length of employee's service for the company.

*Hire Date* typically is the date when employee has accepted or signed the offer.

*Start Date* typically is the date of the first official work day since which employee is
entitled to receiving benefits and various accrual allocations.

*Termination Date* typically is the date of the last official work day since until which employee
is entitled to receiving benefits and various accrual allocations.
Binary file added hr_employee_service/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading