forked from OCA/hr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mig][IMP]hr_employee_age:Migration to 11.0.
- Loading branch information
1 parent
af8b3d3
commit 5a489e7
Showing
10 changed files
with
50 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
=========== | ||
|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | ||
|
@@ -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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters