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

[MIG] 10.0 Porting hr_employee_age #293

Merged
merged 2 commits into from Nov 29, 2016
Merged

[MIG] 10.0 Porting hr_employee_age #293

merged 2 commits into from Nov 29, 2016

Conversation

Yopli2k
Copy link

@Yopli2k Yopli2k commented Nov 16, 2016

No description provided.

@oca-clabot
Copy link

Hey @Yopli2k, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/website.cla
Here is a list of the users:

  • @Yopli2k (login unknown in OCA database)

Appreciation of efforts,
OCA CLAbot

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little changes.


from openerp import fields, models, api
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as OE_DFORMAT
from openerp import api, fields, models
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use from odoo instead of from openerp, as now in version 10 is the default namespace.

@@ -33,9 +32,11 @@ class HrEmployee(models.Model):
)

@api.one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@api.one is deprecated now (they have decided in this way although here is useful), so better to remove in favor of @api.multi and a loop with for record in self: and the rest of the stuff replacing self by record.

dToday = datetime.now().date()
self.age = dToday.year - dBday.year - ((
dToday.month, dToday.day) < (dBday.month, dBday.day))
dBday = fields.Date.from_string(self.birthday)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use upper letters in local variable names (that's something wrong also in the previous version). See PEP8 https://www.python.org/dev/peps/pep-0008/#function-names

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i use the same variables as they were. I'm aiming for future changes. Thank you

dToday.month, dToday.day) < (dBday.month, dBday.day))
dBday = fields.Date.from_string(self.birthday)
dToday = fields.Date.from_string(fields.Date.today())
self.age = relativedelta(dToday, dBday).years
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can do directly the substraction of one date minus the other and you will get a relativedelta object.

@Yopli2k
Copy link
Author

Yopli2k commented Nov 16, 2016

Ok, all changes are now made to the new commit.

dToday.month, dToday.day) < (dBday.month, dBday.day))
for record in self:
if record.birthday:
record.age = relativedelta(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to do:

record.age = (fields.Date.from_string(fields.Date.today()) - fields.Date.from_string(record.birthday)).years

and you save also an import.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code you propose gives me the following error:

File "~/Odoo10/hr/hr_employee_age/models/hr_employee.py", line 39, in _compute_age record.age = (fields.Date.from_string(fields.Date.today()) - fields.Date.from_string(record.birthday)).years **AttributeError: 'datetime.timedelta' object has no attribute 'years'**

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, the returned object is not the same. Well, you can get it with a division, but let's keep this way then

@pedrobaeza pedrobaeza mentioned this pull request Nov 16, 2016
58 tasks
@rafaelbn
Copy link
Member

Rebuilding for testing

Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in runbot

@pedrobaeza pedrobaeza merged commit 43ca279 into OCA:10.0 Nov 29, 2016
leemannd pushed a commit to leemannd/hr that referenced this pull request Jun 12, 2017
feketemihai pushed a commit to feketemihai/hr that referenced this pull request Nov 14, 2017
Trivedi-Vacha-SerpentCS pushed a commit to Trivedi-Vacha-SerpentCS/hr that referenced this pull request Jul 3, 2018
Trivedi-Vacha-SerpentCS pushed a commit to Trivedi-Vacha-SerpentCS/hr that referenced this pull request Oct 3, 2018
Chandresh-SerpentCS pushed a commit to Chandresh-SerpentCS/hr that referenced this pull request Nov 24, 2018
Chandresh-SerpentCS pushed a commit to Chandresh-SerpentCS/hr that referenced this pull request Nov 25, 2018
# The first commit's message is:
OCA Transbot updated translations from Transifex

# This is the 2nd commit message:

OCA Transbot updated translations from Transifex

# This is the 3rd commit message:

OCA Transbot updated translations from Transifex

# This is the 4th commit message:

OCA Transbot updated translations from Transifex

# This is the 5th commit message:

OCA Transbot updated translations from Transifex

# This is the 6th commit message:

OCA Transbot updated translations from Transifex

# This is the 7th commit message:

[MIG] Make modules uninstallable

# This is the 8th commit message:

[FIX] remove en.po that was erroneously created by transbot

# This is the 9th commit message:

[MIG] Rename manifest files

# This is the 10th commit message:

[MIG] 10.0 Porting hr_employee_age (OCA#293)

# This is the 11th commit message:

OCA Transbot updated translations from Transifex

# This is the 12th commit message:

OCA Transbot updated translations from Transifex

# This is the 13th commit message:

OCA Transbot updated translations from Transifex

# This is the 14th commit message:

OCA Transbot updated translations from Transifex

# This is the 15th commit message:

OCA Transbot updated translations from Transifex

# This is the 16th commit message:

OCA Transbot updated translations from Transifex

# This is the 17th commit message:

OCA Transbot updated translations from Transifex

# This is the 18th commit message:

OCA Transbot updated translations from Transifex

# This is the 19th commit message:

OCA Transbot updated translations from Transifex

# This is the 20th commit message:

OCA Transbot updated translations from Transifex

# This is the 21st commit message:

OCA Transbot updated translations from Transifex
i-vyshnevska pushed a commit to i-vyshnevska/hr that referenced this pull request Mar 5, 2019
i-vyshnevska pushed a commit to i-vyshnevska/hr that referenced this pull request Mar 12, 2019
Trivedi-Vacha-SerpentCS pushed a commit to Trivedi-Vacha-SerpentCS/hr that referenced this pull request Jul 29, 2019
mclaeysb pushed a commit to coopiteasy/hr that referenced this pull request Jan 16, 2020
Saran440 pushed a commit to ecosoft-odoo/hr that referenced this pull request Feb 25, 2020
komsan-S pushed a commit to ecosoft-odoo/hr that referenced this pull request Nov 9, 2020
komsan-S pushed a commit to ecosoft-odoo/hr that referenced this pull request Nov 10, 2020
komsan-S pushed a commit to ecosoft-odoo/hr that referenced this pull request Nov 10, 2020
kittiu pushed a commit to ecosoft-odoo/hr that referenced this pull request Feb 27, 2021
pegonzalezspesol pushed a commit to pegonzalezspesol/hr that referenced this pull request Dec 9, 2021
pegonzalezspesol pushed a commit to pegonzalezspesol/hr that referenced this pull request Jul 5, 2022
destroT pushed a commit to destroT/hr that referenced this pull request Apr 6, 2023
destroT pushed a commit to destroT/hr that referenced this pull request Apr 17, 2023
manishkumarbohra pushed a commit to manishkumarbohra/hr that referenced this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants