mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-25 07:32:00 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright (C) 2015 Salton Massally (<smassally@idtlabs.sl>).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import hr_employee
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright (C) 2015 Salton Massally (<smassally@idtlabs.sl>).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class HrEmployee(models.Model):
|
||||
_inherit = "hr.employee"
|
||||
|
||||
# The age field uses a depends (birthday) that has defined
|
||||
# groups="hr.group_hr_user", if a user without permissions in HR tries to get
|
||||
# the value of this field will have an error.
|
||||
# The correct way to avoid this inconsistency is to define groups to field age
|
||||
age = fields.Integer(compute="_compute_age", groups="hr.group_hr_user")
|
||||
|
||||
@api.depends("birthday")
|
||||
def _compute_age(self):
|
||||
for record in self:
|
||||
age = 0
|
||||
if record.birthday:
|
||||
age = relativedelta(fields.Date.today(), record.birthday).years
|
||||
record.age = age
|
||||
Loading…
Add table
Add a link
Reference in a new issue