Skip to content

Commit

Permalink
[Mig][IMP]hr_employee_age:Migration to 11.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trivedi-Vacha-SerpentCS authored and kittiu committed Feb 27, 2021
1 parent af8b3d3 commit 5a489e7
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 94 deletions.
17 changes: 9 additions & 8 deletions hr_employee_age/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Installation

To install this module, you need to:

* clone the branch 8.0 of the repository https://github.com/OCA/hr
* clone the branch 11.0 of the repository https://github.com/OCA/hr
* add the path to this repository in your configuration (addons-path)
* update the module list
* search for "Employee Age" in your addons
Expand All @@ -26,11 +26,11 @@ shown above.

Usage
=====
When you add the birthday of an employee, the age of an employee will auto-populate.


Known issues / Roadmap
======================

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/116/11.0

Bug Tracker
===========
Expand All @@ -47,16 +47,17 @@ Contributors
------------

* Salton Massally (iDT Labs) <[email protected]>
* Serpent Consulting Services Pvt. Ltd. <[email protected]>

Maintainer
----------

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

This module is maintained by the OCA.

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.

To contribute to this module, please visit http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.
21 changes: 2 additions & 19 deletions hr_employee_age/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright (C) 2015 Salton Massally (<[email protected]>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
# Copyright (C) 2015 Salton Massally (<[email protected]>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
25 changes: 4 additions & 21 deletions hr_employee_age/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright (C) 2015 Salton Massally (<[email protected]>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
# Copyright (C) 2015 Salton Massally (<[email protected]>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Employee Age",
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'license': 'AGPL-3',
'author': "Salton Massally <[email protected]>, "
"Odoo Community Association (OCA)",
"website": "http://idtlabs.sl",
"website": "https://github.com/OCA/hr",
"category": "Human Resources",
"summary": "Age field for employee",
"depends": [
Expand Down
2 changes: 1 addition & 1 deletion hr_employee_age/i18n/hr_employee_age.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
Expand Down
21 changes: 2 additions & 19 deletions hr_employee_age/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright (C) 2015 Salton Massally (<[email protected]>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
# Copyright (C) 2015 Salton Massally (<[email protected]>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import hr_employee
31 changes: 7 additions & 24 deletions hr_employee_age/models/hr_employee.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright (C) 2015 Salton Massally (<[email protected]>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
# Copyright (C) 2015 Salton Massally (<[email protected]>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from dateutil.relativedelta import relativedelta

from odoo import api, fields, models
from dateutil.relativedelta import relativedelta


class HrEmployee(models.Model):
Expand All @@ -28,16 +11,16 @@ class HrEmployee(models.Model):
age = fields.Integer(
string='Age',
readonly=True,
compute='_compute_age'
compute='_compute_age',
)

@api.multi
@api.depends('birthday')
def _compute_age(self):
for record in self:
age = 0
if record.birthday:
record.age = relativedelta(
age = relativedelta(
fields.Date.from_string(fields.Date.today()),
fields.Date.from_string(record.birthday)).years
else:
record.age = 0
record.age = age
Binary file added hr_employee_age/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.
2 changes: 2 additions & 0 deletions hr_employee_age/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_hr_employee
21 changes: 21 additions & 0 deletions hr_employee_age/tests/test_hr_employee.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from dateutil.relativedelta import relativedelta
from odoo import fields
from odoo.tests import common


class TestHrEmployee(common.TransactionCase):
def setUp(self):
super(TestHrEmployee, self).setUp()
self.emp_root = self.env.ref('hr.employee_root')
self.emp_root.write({
'birthday': '1990-05-15'
})

def test_compute_age(self):
self.emp_root._compute_age()
age = relativedelta(
fields.Date.from_string(fields.Date.today()),
fields.Date.from_string(self.emp_root.birthday)).years
self.assertEqual(self.emp_root.age, age)
4 changes: 2 additions & 2 deletions hr_employee_age/views/hr_employee.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='birthday']" position="after">
<field name='birthday' position="after">
<field name="age"/>
</xpath>
</field>
</field>
</record>
</odoo>

0 comments on commit 5a489e7

Please sign in to comment.