Skip to content

Commit f4d8a1e

Browse files
[ADD]hr_attendance_work_model
Distinguish the work model for each Attendance
1 parent 35483e8 commit f4d8a1e

16 files changed

+736
-0
lines changed

hr_attendance_work_model/README.rst

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
=====================
2+
Attendance Work Model
3+
=====================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:6925cd9b3a13b0f3fa4b20d5440b0ca7dee18cb408d7c6ef111362ccc93c6d64
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
18+
:alt: License: LGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github
20+
:target: https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_work_model
21+
:alt: OCA/hr-attendance
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/hr-attendance-17-0/hr-attendance-17-0-hr_attendance_work_model
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&target_branch=17.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This addon adds the field **Work Model Type** to Attendances, so the
32+
work model of each attendance can be tracked.
33+
34+
**Table of contents**
35+
36+
.. contents::
37+
:local:
38+
39+
Configuration
40+
=============
41+
42+
In order to distinguish which are the Attendances are remote, it will be
43+
needed to specify the IP Addresses that belong to the Office/s for each
44+
company on it's form view.
45+
46+
Bug Tracker
47+
===========
48+
49+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-attendance/issues>`_.
50+
In case of trouble, please check there if your issue has already been reported.
51+
If you spotted it first, help us to smash it by providing a detailed and welcomed
52+
`feedback <https://github.com/OCA/hr-attendance/issues/new?body=module:%20hr_attendance_work_model%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
53+
54+
Do not contact contributors directly about support or help with technical issues.
55+
56+
Credits
57+
=======
58+
59+
Authors
60+
-------
61+
62+
* ForgeFlow S.L.
63+
64+
Contributors
65+
------------
66+
67+
- Guillem Casassas <guillem.casassas@forgeflow.com>
68+
69+
Maintainers
70+
-----------
71+
72+
This module is maintained by the OCA.
73+
74+
.. image:: https://odoo-community.org/logo.png
75+
:alt: Odoo Community Association
76+
:target: https://odoo-community.org
77+
78+
OCA, or the Odoo Community Association, is a nonprofit organization whose
79+
mission is to support the collaborative development of Odoo features and
80+
promote its widespread use.
81+
82+
.. |maintainer-GuillemCForgeFlow| image:: https://github.com/GuillemCForgeFlow.png?size=40px
83+
:target: https://github.com/GuillemCForgeFlow
84+
:alt: GuillemCForgeFlow
85+
86+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
87+
88+
|maintainer-GuillemCForgeFlow|
89+
90+
This module is part of the `OCA/hr-attendance <https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_work_model>`_ project on GitHub.
91+
92+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

hr_attendance_work_model/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2025 ForgeFlow, S.L.
2+
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).
3+
{
4+
"name": "Attendance Work Model",
5+
"summary": """
6+
Trace the Work Model of the attendances
7+
""",
8+
"version": "17.0.1.0.0",
9+
"category": "Human Resources",
10+
"website": "https://github.com/OCA/hr-attendance",
11+
"author": "ForgeFlow S.L., Odoo Community Association (OCA)",
12+
"maintainers": ["GuillemCForgeFlow"],
13+
"license": "LGPL-3",
14+
"depends": ["hr_attendance"],
15+
"data": [
16+
"security/ir.model.access.csv",
17+
"views/hr_attendance_views.xml",
18+
"views/res_company_views.xml",
19+
],
20+
}

hr_attendance_work_model/i18n/es.po

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * hr_attendance_work_model
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 17.0+e\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2025-03-10 12:56+0000\n"
10+
"PO-Revision-Date: 2025-03-10 12:56+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: hr_attendance_work_model
19+
#: model:ir.model,name:hr_attendance_work_model.model_hr_attendance
20+
msgid "Attendance"
21+
msgstr "Asistencia"
22+
23+
#. module: hr_attendance_work_model
24+
#: model:ir.model,name:hr_attendance_work_model.model_res_company
25+
msgid "Companies"
26+
msgstr "Compañías"
27+
28+
#. module: hr_attendance_work_model
29+
#: model:ir.model,name:hr_attendance_work_model.model_res_company_ip_address
30+
msgid "Company's IP Addresses"
31+
msgstr "Direcciones IP de la compañía"
32+
33+
#. module: hr_attendance_work_model
34+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_res_company_ip_address__create_uid
35+
msgid "Created by"
36+
msgstr "Creado por"
37+
38+
#. module: hr_attendance_work_model
39+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_res_company_ip_address__create_date
40+
msgid "Created on"
41+
msgstr "Creado el"
42+
43+
#. module: hr_attendance_work_model
44+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_res_company_ip_address__display_name
45+
msgid "Display Name"
46+
msgstr "Nombre"
47+
48+
#. module: hr_attendance_work_model
49+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_res_company_ip_address__id
50+
msgid "ID"
51+
msgstr "ID"
52+
53+
#. module: hr_attendance_work_model
54+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_res_company_ip_address__write_uid
55+
msgid "Last Updated by"
56+
msgstr "Última actualización por"
57+
58+
#. module: hr_attendance_work_model
59+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_res_company_ip_address__write_date
60+
msgid "Last Updated on"
61+
msgstr "Última actualización el"
62+
63+
#. module: hr_attendance_work_model
64+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_res_company_ip_address__name
65+
msgid "Name"
66+
msgstr "Nombre"
67+
68+
#. module: hr_attendance_work_model
69+
#: model:ir.model.fields.selection,name:hr_attendance_work_model.selection__hr_attendance__work_model_type__office
70+
msgid "Office"
71+
msgstr "Oficina"
72+
73+
#. module: hr_attendance_work_model
74+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_res_company__office_ip_address_ids
75+
msgid "Offices' IP Addresses"
76+
msgstr "Direcciones IP de las oficinas"
77+
78+
#. module: hr_attendance_work_model
79+
#: model:ir.model.fields.selection,name:hr_attendance_work_model.selection__hr_attendance__work_model_type__remote
80+
msgid "Remote"
81+
msgstr "Remoto"
82+
83+
#. module: hr_attendance_work_model
84+
#: model:ir.model.fields,field_description:hr_attendance_work_model.field_hr_attendance__work_model_type
85+
msgid "Work Model"
86+
msgstr "Modelo de trabajo"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import hr_attendance
2+
from . import res_company_ip_address
3+
from . import res_company
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from odoo import api, fields, models
2+
3+
4+
class HrAttendance(models.Model):
5+
_inherit = "hr.attendance"
6+
7+
work_model_type = fields.Selection(
8+
selection=[
9+
("office", "Office"),
10+
("remote", "Remote"),
11+
],
12+
string="Work Model",
13+
compute="_compute_work_model_type",
14+
store=True,
15+
)
16+
17+
@api.depends(
18+
"employee_id.company_id.office_ip_address_ids",
19+
"in_ip_address",
20+
"out_ip_address",
21+
)
22+
def _compute_work_model_type(self):
23+
office_ip_address_by_company_dict = {
24+
company.id: [
25+
ip_address.name for ip_address in company.office_ip_address_ids
26+
]
27+
for company in self.env["res.company"].search([])
28+
}
29+
for attendance in self:
30+
company_id = attendance.employee_id.company_id.id
31+
office_ip_addresses = office_ip_address_by_company_dict.get(
32+
company_id, False
33+
)
34+
work_model_type = "office"
35+
ip_address = attendance.out_ip_address or attendance.in_ip_address
36+
for office_ip_address in office_ip_addresses:
37+
if office_ip_address and ip_address and ip_address != office_ip_address:
38+
work_model_type = "remote"
39+
break
40+
attendance.work_model_type = work_model_type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from odoo import fields, models
2+
3+
4+
class ResCompany(models.Model):
5+
_inherit = "res.company"
6+
7+
office_ip_address_ids = fields.Many2many(
8+
comodel_name="res.company.ip.address", string="Offices' IP Addresses"
9+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from odoo import fields, models
2+
3+
4+
class ResCompanyIPAddress(models.Model):
5+
_name = "res.company.ip.address"
6+
_description = "Company's IP Addresses"
7+
8+
name = fields.Char(required=True)
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In order to distinguish which are the Attendances are remote, it will be needed to
2+
specify the IP Addresses that belong to the Office/s for each company on it's form view.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Guillem Casassas \<<guillem.casassas@forgeflow.com>\>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This addon adds the field **Work Model Type** to Attendances, so the work model of each
2+
attendance can be tracked.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2+
access_res_company_ip_address,access_res_company_ip_address,model_res_company_ip_address,base.group_user,1,0,0,0
3+
access_res_company_ip_address_manager,access_res_company_ip_address_manager,model_res_company_ip_address,hr_attendance.group_hr_attendance_manager,1,1,1,1

0 commit comments

Comments
 (0)