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

[15.0][ENH] hr_operating_unit: add OU to department #562

Open
wants to merge 2 commits into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions hr_operating_unit/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ HR Operating Unit

This module introduces the following features:

* Adds the Operating Unit (OU) to the Employee.
* Adds the Operating Unit (OU) to the Employee/Department.

* The Employees's default Operating Unit (OU) is proposed at the time of creation
getting it from the logged user.
Expand All @@ -43,7 +43,7 @@ This module introduces the following features:
Usage
=====

Add the operating unit to Employee
Add the operating unit to Employee/Department

Bug Tracker
===========
Expand All @@ -68,6 +68,7 @@ Contributors

* Gonzalo González Domínguez <[email protected]>
* Murtaza Mithaiwala <[email protected]>
* Pimolnat Suntian <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
3 changes: 2 additions & 1 deletion hr_operating_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"depends": ["hr", "operating_unit"],
"data": [
"security/security.xml",
"views/hr_employee.xml",
"views/hr_department_views.xml",
"views/hr_employee_views.xml",
],
"installable": True,
}
1 change: 1 addition & 0 deletions hr_operating_unit/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import hr_department
from . import hr_employee_base
from . import hr_operating_unit
15 changes: 15 additions & 0 deletions hr_operating_unit/models/hr_department.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class Department(models.Model):
_inherit = "hr.department"
_check_company_auto = True

operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Operating Unit",
default=lambda self: (self.env["res.users"].operating_unit_default_get()),
check_company=True,
)
15 changes: 10 additions & 5 deletions hr_operating_unit/models/hr_operating_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ class OperatingUnit(models.Model):
_inherit = "operating.unit"

employee_ids = fields.Many2many(
"hr.employee",
"operating_unit_employees_rel",
"operating_unit_id",
"employee_id",
"Employees Allowed",
comodel_name="hr.employee",
relation="operating_unit_employees_rel",
column1="operating_unit_id",
column2="employee_id",
string="Employees Allowed",
)
department_ids = fields.One2many(
comodel_name="hr.department",
inverse_name="operating_unit_id",
string="Departments",
)
1 change: 1 addition & 0 deletions hr_operating_unit/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Gonzalo González Domínguez <[email protected]>
* Murtaza Mithaiwala <[email protected]>
* Pimolnat Suntian <[email protected]>
2 changes: 1 addition & 1 deletion hr_operating_unit/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This module introduces the following features:

* Adds the Operating Unit (OU) to the Employee.
* Adds the Operating Unit (OU) to the Employee/Department.

* The Employees's default Operating Unit (OU) is proposed at the time of creation
getting it from the logged user.
2 changes: 1 addition & 1 deletion hr_operating_unit/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Add the operating unit to Employee
Add the operating unit to Employee/Department
14 changes: 14 additions & 0 deletions hr_operating_unit/security/security.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="ir_rule_hr_department_allowed_operating_units" model="ir.rule">
<field name="model_id" ref="hr.model_hr_department" />
<field name="domain_force">['|',
('operating_unit_id', '=', False),
('operating_unit_id', 'in', user.operating_unit_ids.ids)]
</field>
<field name="name">Department from allowed operating units</field>
<field eval="0" name="perm_unlink" />
<field eval="0" name="perm_write" />
<field eval="1" name="perm_read" />
<field eval="0" name="perm_create" />
<field name="global" eval="True" />
</record>

<record id="ir_rule_hr_allowed_operating_units" model="ir.rule">
<field name="model_id" ref="hr.model_hr_employee" />
<field
Expand Down
6 changes: 3 additions & 3 deletions hr_operating_unit/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -372,7 +371,7 @@ <h1 class="title">HR Operating Unit</h1>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/operating-unit/tree/15.0/hr_operating_unit"><img alt="OCA/operating-unit" src="https://img.shields.io/badge/github-OCA%2Foperating--unit-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/operating-unit-15-0/operating-unit-15-0-hr_operating_unit"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/operating-unit&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module introduces the following features:</p>
<ul class="simple">
<li>Adds the Operating Unit (OU) to the Employee.</li>
<li>Adds the Operating Unit (OU) to the Employee/Department.</li>
<li>The Employees’s default Operating Unit (OU) is proposed at the time of creation
getting it from the logged user.</li>
</ul>
Expand All @@ -391,7 +390,7 @@ <h1 class="title">HR Operating Unit</h1>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>Add the operating unit to Employee</p>
<p>Add the operating unit to Employee/Department</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
Expand All @@ -414,6 +413,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li>Gonzalo González Domínguez &lt;<a class="reference external" href="mailto:meigallo&#64;meigallodixital.com">meigallo&#64;meigallodixital.com</a>&gt;</li>
<li>Murtaza Mithaiwala &lt;<a class="reference external" href="mailto:mmithaiwala&#64;opensourceintegrators.com">mmithaiwala&#64;opensourceintegrators.com</a>&gt;</li>
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
45 changes: 45 additions & 0 deletions hr_operating_unit/views/hr_department_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_department_form" model="ir.ui.view">
<field name="model">hr.department</field>
<field name="inherit_id" ref="hr.view_department_form" />
<field name="arch" type="xml">
<field name="parent_id" position="after">
<field
name="operating_unit_id"
options="{'no_create': True}"
groups="operating_unit.group_multi_operating_unit"
/>
</field>
</field>
</record>
<record id="view_department_tree" model="ir.ui.view">
<field name="model">hr.department</field>
<field name="inherit_id" ref="hr.view_department_tree" />
<field name="arch" type="xml">
<field name="parent_id" position="after">
<field
name="operating_unit_id"
groups="operating_unit.group_multi_operating_unit"
optional="hide"
/>
</field>
</field>
</record>
<record id="view_department_filter" model="ir.ui.view">
<field name="model">hr.department</field>
<field name="inherit_id" ref="hr.view_department_filter" />
<field name="arch" type="xml">
<field name="manager_id" position="after">
<field name="operating_unit_id" />
</field>
<filter name="inactive" position="after">
<filter
string="Operating Unit"
name="operating_unit_id"
context="{'group_by': 'operating_unit_id'}"
/>
</filter>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<field name="company_id" position="after">
<field
name="operating_unit_ids"
domain="[('user_ids', 'in', uid)]"
groups="operating_unit.group_multi_operating_unit"
widget="many2many_tags"
options="{'no_create': True}"
Expand Down
Loading