Skip to content

Commit baa383c

Browse files
meigallodixitalBorruso
authored andcommittedSep 22, 2023
This module introduces Operating Units in Employees
1 parent a403b28 commit baa383c

14 files changed

+719
-0
lines changed
 

‎hr_operating_unit/README.rst

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
=================
2+
HR Operating Unit
3+
=================
4+
5+
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
6+
!! This file is generated by oca-gen-addon-readme !!
7+
!! changes will be overwritten. !!
8+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
10+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
11+
:target: https://odoo-community.org/page/development-status
12+
:alt: Beta
13+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
14+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
15+
:alt: License: AGPL-3
16+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github
17+
:target: https://github.com/OCA/operating-unit/tree/12.0/hr_operating_unit
18+
:alt: OCA/operating-unit
19+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
20+
:target: https://translation.odoo-community.org/projects/operating-unit-12-0/operating-unit-12-0-hr_operating_unit
21+
:alt: Translate me on Weblate
22+
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23+
:target: https://runbot.odoo-community.org/runbot/213/12.0
24+
:alt: Try me on Runbot
25+
26+
|badge1| |badge2| |badge3| |badge4| |badge5|
27+
28+
This module introduces the following features:
29+
30+
* Adds the Operating Unit (OU) to the Employee.
31+
32+
* The Employees's default Operating Unit (OU) is proposed at the time of creating
33+
getting the logged user one.
34+
35+
36+
**Table of contents**
37+
38+
.. contents::
39+
:local:
40+
41+
Usage
42+
=====
43+
44+
Add the operating unit to Employee
45+
46+
Bug Tracker
47+
===========
48+
49+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/operating-unit/issues>`_.
50+
In case of trouble, please check there if your issue has already been reported.
51+
If you spotted it first, help us smashing it by providing a detailed and welcomed
52+
`feedback <https://github.com/OCA/operating-unit/issues/new?body=module:%20hr_operating_unit%0Aversion:%2012.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+
* Gonzalo González Domí­nguez
63+
64+
Contributors
65+
~~~~~~~~~~~~
66+
67+
* Gonzalo González Domínguez <meigallo@meigallodixital.com>
68+
69+
70+
Maintainers
71+
~~~~~~~~~~~
72+
73+
This module is maintained by the OCA.
74+
75+
.. image:: https://odoo-community.org/logo.png
76+
:alt: Odoo Community Association
77+
:target: https://odoo-community.org
78+
79+
OCA, or the Odoo Community Association, is a nonprofit organization whose
80+
mission is to support the collaborative development of Odoo features and
81+
promote its widespread use.
82+
83+
This module is part of the `OCA/operating-unit <https://github.com/OCA/operating-unit/tree/12.0/hr_operating_unit>`_ project on GitHub.
84+
85+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

‎hr_operating_unit/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import models

‎hr_operating_unit/__manifest__.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
{
3+
"name": "HR Operating Unit",
4+
"version": "12.0.1.0.0",
5+
"author": "Gonzalo González Domínguez,"
6+
"Odoo Community Association (OCA)",
7+
"license": "AGPL-3",
8+
"website": "https://github.com/OCA/operating-unit",
9+
"category": "Human Resources",
10+
"depends": ["hr", "operating_unit"],
11+
"data": [
12+
"security/security.xml",
13+
"views/hr_employee.xml",
14+
],
15+
'installable': True,
16+
}

‎hr_operating_unit/i18n/es.po

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * hr_operating_unit
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 12.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2019-05-13 11:03+0000\n"
10+
"PO-Revision-Date: 2019-05-13 11:03+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_operating_unit
19+
#: model:ir.model.fields,field_description:hr_operating_unit.field_hr_employee__default_operating_unit_id
20+
#: model_terms:ir.ui.view,arch_db:hr_operating_unit.view_employee_filter
21+
msgid "Default Operating Unit"
22+
msgstr "Unidad Operativa Actual"
23+
24+
#. module: hr_operating_unit
25+
#: model:ir.model,name:hr_operating_unit.model_hr_employee
26+
msgid "Employee"
27+
msgstr "Empleado"
28+
29+
#. module: hr_operating_unit
30+
#: model:ir.model.fields,field_description:hr_operating_unit.field_operating_unit__employee_ids
31+
msgid "Employees Allowed"
32+
msgstr "Empleados Permitidos"
33+
34+
#. module: hr_operating_unit
35+
#: model:ir.model,name:hr_operating_unit.model_operating_unit
36+
msgid "Operating Unit"
37+
msgstr "Unidad Operativa"
38+
39+
#. module: hr_operating_unit
40+
#: model:ir.model.fields,field_description:hr_operating_unit.field_hr_employee__operating_unit_ids
41+
msgid "Operating Units"
42+
msgstr "Unidades Operativas"
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * hr_operating_unit
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 12.0\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2019-05-13 11:02+0000\n"
10+
"PO-Revision-Date: 2019-05-13 11:02+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_operating_unit
19+
#: model:ir.model.fields,field_description:hr_operating_unit.field_hr_employee__default_operating_unit_id
20+
#: model_terms:ir.ui.view,arch_db:hr_operating_unit.view_employee_filter
21+
msgid "Default Operating Unit"
22+
msgstr ""
23+
24+
#. module: hr_operating_unit
25+
#: model:ir.model,name:hr_operating_unit.model_hr_employee
26+
msgid "Employee"
27+
msgstr ""
28+
29+
#. module: hr_operating_unit
30+
#: model:ir.model.fields,field_description:hr_operating_unit.field_operating_unit__employee_ids
31+
msgid "Employees Allowed"
32+
msgstr ""
33+
34+
#. module: hr_operating_unit
35+
#: model:ir.model,name:hr_operating_unit.model_operating_unit
36+
msgid "Operating Unit"
37+
msgstr ""
38+
39+
#. module: hr_operating_unit
40+
#: model:ir.model.fields,field_description:hr_operating_unit.field_hr_employee__operating_unit_ids
41+
msgid "Operating Units"
42+
msgstr ""
43+

‎hr_operating_unit/models/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from . import hr_employee
4+
from . import hr_operating_unit
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from odoo import fields, models
4+
5+
6+
class HrEmployee(models.Model):
7+
_inherit = 'hr.employee'
8+
9+
operating_unit_ids = fields.Many2many(
10+
'operating.unit', 'operating_unit_employees_rel', 'employee_id',
11+
'poid', 'Operating Units',
12+
default=lambda self: (
13+
self.env['res.users'].operating_unit_default_get())
14+
)
15+
16+
default_operating_unit_id = fields.Many2one(
17+
'operating.unit', 'Default Operating Unit',
18+
default=lambda self: (
19+
self.env['res.users'].operating_unit_default_get())
20+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from odoo import fields, models
4+
5+
6+
class HrOperatingUnit(models.Model):
7+
_inherit = 'operating.unit'
8+
9+
employee_ids = fields.Many2many(
10+
'hr.employee', 'operating_unit_employees_rel', 'poid', 'employee_id',
11+
'Employees Allowed',
12+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Gonzalo González Domínguez <meigallo@meigallodixital.com>
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This module introduces the following features:
2+
3+
* Adds the Operating Unit (OU) to the Employee.
4+
5+
* The Employees's default Operating Unit (OU) is proposed at the time of creation
6+
getting it from the logged user.
7+

‎hr_operating_unit/readme/USAGE.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add the operating unit to Employee
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
4+
<record id="ir_rule_hr_allowed_operating_units" model="ir.rule">
5+
<field name="model_id" ref="hr.model_hr_employee"/>
6+
<field name="domain_force">['|',('default_operating_unit_id','=',False),('default_operating_unit_id','in', user.operating_unit_ids.ids)]</field>
7+
<field name="name">Allowed Operating Units for Employee</field>
8+
<field eval="0" name="perm_unlink"/>
9+
<field eval="0" name="perm_write"/>
10+
<field eval="1" name="perm_read"/>
11+
<field eval="0" name="perm_create"/>
12+
<field name="global" eval="True"/>
13+
</record>
14+
15+
</odoo>

‎hr_operating_unit/static/description/index.html

+429
Large diffs are not rendered by default.
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<!--- Operating Unit views -->
4+
<record id="view_employee_tree" model="ir.ui.view">
5+
<field name="name">hr.employee_tree</field>
6+
<field name="model">hr.employee</field>
7+
<field name="inherit_id" ref="hr.view_employee_tree" />
8+
<field name="arch" type="xml">
9+
<field name="department_id" position="before">
10+
<field name="default_operating_unit_id" groups="operating_unit.group_multi_operating_unit"/>
11+
</field>
12+
</field>
13+
</record>
14+
15+
<record id="view_employee_form" model="ir.ui.view">
16+
<field name="name">hr.employee_form</field>
17+
<field name="model">hr.employee</field>
18+
<field name="inherit_id" ref="hr.view_employee_form" />
19+
<field name="arch" type="xml">
20+
<field name="department_id" position="before">
21+
<field name="default_operating_unit_id" domain="[('id', 'in', operating_unit_ids)]" options="{'no_create': True}" />
22+
</field>
23+
<field name="company_id" position="after">
24+
<field name="operating_unit_ids" domain="[('user_ids', 'in', uid)]" groups="operating_unit.group_multi_operating_unit" widget="many2many_tags" options="{'no_create': True}" />
25+
</field>
26+
</field>
27+
</record>
28+
29+
<record id="view_employee_filter" model="ir.ui.view">
30+
<field name="name">hr.employee_filter</field>
31+
<field name="model">hr.employee</field>
32+
<field name="inherit_id" ref="hr.view_employee_filter" />
33+
<field name="arch" type="xml">
34+
<field name="department_id" position="before">
35+
<field name="default_operating_unit_id" groups="operating_unit.group_multi_operating_unit"/>
36+
<filter name="group_default_operating_unit" groups="operating_unit.group_multi_operating_unit" string="Default Operating Unit" context="{'group_by':'default_operating_unit_id'}"/>
37+
</field>
38+
</field>
39+
</record>
40+
</odoo>

0 commit comments

Comments
 (0)
Please sign in to comment.