odoo-addon-analytic-hr-department-restriction 16.0.1.0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/analytic_hr_department_restriction/README.rst +106 -0
- odoo/addons/analytic_hr_department_restriction/__init__.py +1 -0
- odoo/addons/analytic_hr_department_restriction/__manifest__.py +18 -0
- odoo/addons/analytic_hr_department_restriction/i18n/analytic_hr_department_restriction.pot +41 -0
- odoo/addons/analytic_hr_department_restriction/i18n/es.po +40 -0
- odoo/addons/analytic_hr_department_restriction/models/__init__.py +5 -0
- odoo/addons/analytic_hr_department_restriction/models/account_analytic_account.py +14 -0
- odoo/addons/analytic_hr_department_restriction/models/account_analytic_plan.py +14 -0
- odoo/addons/analytic_hr_department_restriction/models/ir_rule.py +54 -0
- odoo/addons/analytic_hr_department_restriction/readme/CONFIGURE.rst +2 -0
- odoo/addons/analytic_hr_department_restriction/readme/CONTRIBUTORS.rst +4 -0
- odoo/addons/analytic_hr_department_restriction/readme/DESCRIPTION.rst +5 -0
- odoo/addons/analytic_hr_department_restriction/readme/USAGE.rst +5 -0
- odoo/addons/analytic_hr_department_restriction/security/groups.xml +11 -0
- odoo/addons/analytic_hr_department_restriction/static/description/icon.png +0 -0
- odoo/addons/analytic_hr_department_restriction/static/description/index.html +450 -0
- odoo/addons/analytic_hr_department_restriction/tests/__init__.py +4 -0
- odoo/addons/analytic_hr_department_restriction/tests/test_analytic_hr_department_restriction.py +157 -0
- odoo/addons/analytic_hr_department_restriction/views/account_analytic_account_views.xml +43 -0
- odoo/addons/analytic_hr_department_restriction/views/account_analytic_plan_views.xml +30 -0
- odoo_addon_analytic_hr_department_restriction-16.0.1.0.0.2.dist-info/METADATA +121 -0
- odoo_addon_analytic_hr_department_restriction-16.0.1.0.0.2.dist-info/RECORD +24 -0
- odoo_addon_analytic_hr_department_restriction-16.0.1.0.0.2.dist-info/WHEEL +5 -0
- odoo_addon_analytic_hr_department_restriction-16.0.1.0.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
====================================================
|
2
|
+
Analytic distributions restriction per HR department
|
3
|
+
====================================================
|
4
|
+
|
5
|
+
..
|
6
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
7
|
+
!! This file is generated by oca-gen-addon-readme !!
|
8
|
+
!! changes will be overwritten. !!
|
9
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
10
|
+
!! source digest: sha256:e787f119827c6a3cd07a0d80cd200c9f1aea5dc339e7ef2fa58277891f410915
|
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-AGPL--3-blue.png
|
17
|
+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
18
|
+
:alt: License: AGPL-3
|
19
|
+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
|
20
|
+
:target: https://github.com/OCA/account-analytic/tree/16.0/analytic_hr_department_restriction
|
21
|
+
:alt: OCA/account-analytic
|
22
|
+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
23
|
+
:target: https://translation.odoo-community.org/projects/account-analytic-16-0/account-analytic-16-0-analytic_hr_department_restriction
|
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/account-analytic&target_branch=16.0
|
27
|
+
:alt: Try me on Runboat
|
28
|
+
|
29
|
+
|badge1| |badge2| |badge3| |badge4| |badge5|
|
30
|
+
|
31
|
+
This module allows you to limit plans and analytical accounts by employee departments.
|
32
|
+
|
33
|
+
Users will only be able to view plans and analytical accounts linked to their employee's department or those with no department defined.
|
34
|
+
|
35
|
+
Users with the "Invoicing / Billing" permission will be able to view all plans and analytical accounts without restrictions.
|
36
|
+
|
37
|
+
**Table of contents**
|
38
|
+
|
39
|
+
.. contents::
|
40
|
+
:local:
|
41
|
+
|
42
|
+
Configuration
|
43
|
+
=============
|
44
|
+
|
45
|
+
- Your user must have the "Analytic Accounting" permission.
|
46
|
+
- Create an employee linked to your user with a defined department.
|
47
|
+
|
48
|
+
Usage
|
49
|
+
=====
|
50
|
+
|
51
|
+
#. Go to an analytical plan/account and define your employee's department.
|
52
|
+
#. Go to an analytical plan/account and define a different department than your employee's department.
|
53
|
+
#. Go to an analytical plan/account and leave the department empty.
|
54
|
+
#. Users without the "Invoicing / Billing" permission will be able to see only the plans/analytical accounts of the user's employee's department.
|
55
|
+
#. Users with the "Analytic Accounting (without department)" will be able to view the plans/analytical accounts without a department, as will users with the permission "Invoicing / Billing".
|
56
|
+
|
57
|
+
Bug Tracker
|
58
|
+
===========
|
59
|
+
|
60
|
+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/issues>`_.
|
61
|
+
In case of trouble, please check there if your issue has already been reported.
|
62
|
+
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
63
|
+
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20analytic_hr_department_restriction%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
64
|
+
|
65
|
+
Do not contact contributors directly about support or help with technical issues.
|
66
|
+
|
67
|
+
Credits
|
68
|
+
=======
|
69
|
+
|
70
|
+
Authors
|
71
|
+
~~~~~~~
|
72
|
+
|
73
|
+
* Tecnativa
|
74
|
+
|
75
|
+
Contributors
|
76
|
+
~~~~~~~~~~~~
|
77
|
+
|
78
|
+
* `Tecnativa <https://www.tecnativa.com>`__:
|
79
|
+
|
80
|
+
* Víctor Martínez
|
81
|
+
* Pedro M. Baeza
|
82
|
+
|
83
|
+
Maintainers
|
84
|
+
~~~~~~~~~~~
|
85
|
+
|
86
|
+
This module is maintained by the OCA.
|
87
|
+
|
88
|
+
.. image:: https://odoo-community.org/logo.png
|
89
|
+
:alt: Odoo Community Association
|
90
|
+
:target: https://odoo-community.org
|
91
|
+
|
92
|
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
93
|
+
mission is to support the collaborative development of Odoo features and
|
94
|
+
promote its widespread use.
|
95
|
+
|
96
|
+
.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
|
97
|
+
:target: https://github.com/victoralmau
|
98
|
+
:alt: victoralmau
|
99
|
+
|
100
|
+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
101
|
+
|
102
|
+
|maintainer-victoralmau|
|
103
|
+
|
104
|
+
This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/16.0/analytic_hr_department_restriction>`_ project on GitHub.
|
105
|
+
|
106
|
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
@@ -0,0 +1 @@
|
|
1
|
+
from . import models
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright 2025 Tecnativa - Víctor Martínez
|
2
|
+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
3
|
+
{
|
4
|
+
"name": "Analytic distributions restriction per HR department",
|
5
|
+
"author": "Tecnativa, Odoo Community Association (OCA)",
|
6
|
+
"website": "https://github.com/OCA/account-analytic",
|
7
|
+
"version": "16.0.1.0.0",
|
8
|
+
"depends": ["account", "hr"],
|
9
|
+
"license": "AGPL-3",
|
10
|
+
"category": "Account",
|
11
|
+
"installable": True,
|
12
|
+
"maintainers": ["victoralmau"],
|
13
|
+
"data": [
|
14
|
+
"security/groups.xml",
|
15
|
+
"views/account_analytic_account_views.xml",
|
16
|
+
"views/account_analytic_plan_views.xml",
|
17
|
+
],
|
18
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Translation of Odoo Server.
|
2
|
+
# This file contains the translation of the following modules:
|
3
|
+
# * analytic_hr_department_restriction
|
4
|
+
#
|
5
|
+
msgid ""
|
6
|
+
msgstr ""
|
7
|
+
"Project-Id-Version: Odoo Server 16.0\n"
|
8
|
+
"Report-Msgid-Bugs-To: \n"
|
9
|
+
"Last-Translator: \n"
|
10
|
+
"Language-Team: \n"
|
11
|
+
"MIME-Version: 1.0\n"
|
12
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
13
|
+
"Content-Transfer-Encoding: \n"
|
14
|
+
"Plural-Forms: \n"
|
15
|
+
|
16
|
+
#. module: analytic_hr_department_restriction
|
17
|
+
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_account
|
18
|
+
msgid "Analytic Account"
|
19
|
+
msgstr ""
|
20
|
+
|
21
|
+
#. module: analytic_hr_department_restriction
|
22
|
+
#: model:res.groups,name:analytic_hr_department_restriction.group_analytic_accounting_without_department
|
23
|
+
msgid "Analytic Accounting (without department)"
|
24
|
+
msgstr ""
|
25
|
+
|
26
|
+
#. module: analytic_hr_department_restriction
|
27
|
+
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_plan
|
28
|
+
msgid "Analytic Plans"
|
29
|
+
msgstr ""
|
30
|
+
|
31
|
+
#. module: analytic_hr_department_restriction
|
32
|
+
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_account__department_id
|
33
|
+
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_plan__department_id
|
34
|
+
#: model_terms:ir.ui.view,arch_db:analytic_hr_department_restriction.view_account_analytic_account_search
|
35
|
+
msgid "Department"
|
36
|
+
msgstr ""
|
37
|
+
|
38
|
+
#. module: analytic_hr_department_restriction
|
39
|
+
#: model:ir.model,name:analytic_hr_department_restriction.model_ir_rule
|
40
|
+
msgid "Record Rule"
|
41
|
+
msgstr ""
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Translation of Odoo Server.
|
2
|
+
# This file contains the translation of the following modules:
|
3
|
+
# * analytic_hr_department_restriction
|
4
|
+
#
|
5
|
+
msgid ""
|
6
|
+
msgstr ""
|
7
|
+
"Project-Id-Version: Odoo Server 16.0\n"
|
8
|
+
"Report-Msgid-Bugs-To: \n"
|
9
|
+
"POT-Creation-Date: 2025-04-16 14:25+0000\n"
|
10
|
+
"PO-Revision-Date: 2025-04-16 16:26+0200\n"
|
11
|
+
"Last-Translator: \n"
|
12
|
+
"Language-Team: \n"
|
13
|
+
"Language: es\n"
|
14
|
+
"MIME-Version: 1.0\n"
|
15
|
+
"Content-Type: text/plain; charset=UTF-8\n"
|
16
|
+
"Content-Transfer-Encoding: 8bit\n"
|
17
|
+
"Plural-Forms: \n"
|
18
|
+
"X-Generator: Poedit 3.0.1\n"
|
19
|
+
|
20
|
+
#. module: analytic_hr_department_restriction
|
21
|
+
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_account
|
22
|
+
msgid "Analytic Account"
|
23
|
+
msgstr "Cuenta analítica"
|
24
|
+
|
25
|
+
#. module: analytic_hr_department_restriction
|
26
|
+
#: model:res.groups,name:analytic_hr_department_restriction.group_analytic_accounting_without_department
|
27
|
+
msgid "Analytic Accounting (without department)"
|
28
|
+
msgstr "Contabilidad analítica (sin departamento)"
|
29
|
+
|
30
|
+
#. module: analytic_hr_department_restriction
|
31
|
+
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_plan
|
32
|
+
msgid "Analytic Plans"
|
33
|
+
msgstr "Planes analíticos"
|
34
|
+
|
35
|
+
#. module: analytic_hr_department_restriction
|
36
|
+
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_account__department_id
|
37
|
+
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_plan__department_id
|
38
|
+
#: model_terms:ir.ui.view,arch_db:analytic_hr_department_restriction.view_account_analytic_account_search
|
39
|
+
msgid "Department"
|
40
|
+
msgstr "Departamento"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Copyright 2025 Tecnativa - Víctor Martínez
|
2
|
+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
3
|
+
|
4
|
+
from odoo import fields, models
|
5
|
+
|
6
|
+
|
7
|
+
class AccountAnalyticAccount(models.Model):
|
8
|
+
_inherit = "account.analytic.account"
|
9
|
+
|
10
|
+
department_id = fields.Many2one(
|
11
|
+
comodel_name="hr.department",
|
12
|
+
string="Department",
|
13
|
+
domain="['|',('company_id', '=?', company_id),('company_id', '=', False)]",
|
14
|
+
)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Copyright 2025 Tecnativa - Víctor Martínez
|
2
|
+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
3
|
+
|
4
|
+
from odoo import fields, models
|
5
|
+
|
6
|
+
|
7
|
+
class AccountAnalyticPlan(models.Model):
|
8
|
+
_inherit = "account.analytic.plan"
|
9
|
+
|
10
|
+
department_id = fields.Many2one(
|
11
|
+
comodel_name="hr.department",
|
12
|
+
string="Department",
|
13
|
+
domain="['|',('company_id', '=?', company_id),('company_id', '=', False)]",
|
14
|
+
)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright 2025 Tecnativa - Víctor Martínez
|
2
|
+
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
3
|
+
|
4
|
+
from odoo import api, models, tools
|
5
|
+
from odoo.osv import expression
|
6
|
+
from odoo.tools import config
|
7
|
+
|
8
|
+
|
9
|
+
class IrRule(models.Model):
|
10
|
+
_inherit = "ir.rule"
|
11
|
+
|
12
|
+
@api.model
|
13
|
+
@tools.conditional(
|
14
|
+
"xml" not in config["dev_mode"],
|
15
|
+
tools.ormcache(
|
16
|
+
"self.env.uid",
|
17
|
+
"self.env.su",
|
18
|
+
"model_name",
|
19
|
+
"mode",
|
20
|
+
"tuple(self._compute_domain_context_values())",
|
21
|
+
),
|
22
|
+
)
|
23
|
+
def _compute_domain(self, model_name, mode="read"):
|
24
|
+
"""Inject extra domain for restricting plans and analytical accounts when the
|
25
|
+
user has the group 'Analytic Accounting'.
|
26
|
+
"""
|
27
|
+
res = super()._compute_domain(model_name, mode=mode)
|
28
|
+
user = self.env.user
|
29
|
+
group1 = "base.group_user"
|
30
|
+
group2 = "analytic.group_analytic_accounting"
|
31
|
+
group3 = "analytic_hr_department_restriction.group_analytic_accounting_without_department" # noqa: B950
|
32
|
+
group4 = "account.group_account_invoice"
|
33
|
+
test_condition = not config["test_enable"] or self.env.context.get(
|
34
|
+
"test_analytic_hr_department_restriction"
|
35
|
+
)
|
36
|
+
if (
|
37
|
+
model_name in ("account.analytic.account", "account.analytic.plan")
|
38
|
+
and not self.env.su
|
39
|
+
and user.has_group(group1)
|
40
|
+
and not user.has_group(group4)
|
41
|
+
and test_condition
|
42
|
+
):
|
43
|
+
if user.has_group(group2):
|
44
|
+
extra_domain = [
|
45
|
+
("department_id", "child_of", user.employee_ids.department_id.ids)
|
46
|
+
]
|
47
|
+
if user.has_group(group3):
|
48
|
+
extra_domain = expression.OR(
|
49
|
+
[extra_domain, [("department_id", "=", False)]]
|
50
|
+
)
|
51
|
+
else:
|
52
|
+
extra_domain = [("id", "=", 0)]
|
53
|
+
res = expression.AND([extra_domain] + [res])
|
54
|
+
return res
|
@@ -0,0 +1,5 @@
|
|
1
|
+
This module allows you to limit plans and analytical accounts by employee departments.
|
2
|
+
|
3
|
+
Users will only be able to view plans and analytical accounts linked to their employee's department or those with no department defined.
|
4
|
+
|
5
|
+
Users with the "Invoicing / Billing" permission will be able to view all plans and analytical accounts without restrictions.
|
@@ -0,0 +1,5 @@
|
|
1
|
+
#. Go to an analytical plan/account and define your employee's department.
|
2
|
+
#. Go to an analytical plan/account and define a different department than your employee's department.
|
3
|
+
#. Go to an analytical plan/account and leave the department empty.
|
4
|
+
#. Users without the "Invoicing / Billing" permission will be able to see only the plans/analytical accounts of the user's employee's department.
|
5
|
+
#. Users with the "Analytic Accounting (without department)" will be able to view the plans/analytical accounts without a department, as will users with the permission "Invoicing / Billing".
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<odoo>
|
3
|
+
<record id="group_analytic_accounting_without_department" model="res.groups">
|
4
|
+
<field name="name">Analytic Accounting (without department)</field>
|
5
|
+
<field name="category_id" ref="base.module_category_hidden" />
|
6
|
+
<field
|
7
|
+
name="implied_ids"
|
8
|
+
eval="[(4, ref('analytic.group_analytic_accounting'))]"
|
9
|
+
/>
|
10
|
+
</record>
|
11
|
+
</odoo>
|
@@ -0,0 +1,450 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
+
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
|
6
|
+
<title>Analytic distributions restriction per HR department</title>
|
7
|
+
<style type="text/css">
|
8
|
+
|
9
|
+
/*
|
10
|
+
:Author: David Goodger (goodger@python.org)
|
11
|
+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
|
12
|
+
:Copyright: This stylesheet has been placed in the public domain.
|
13
|
+
|
14
|
+
Default cascading style sheet for the HTML output of Docutils.
|
15
|
+
Despite the name, some widely supported CSS2 features are used.
|
16
|
+
|
17
|
+
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
18
|
+
customize this style sheet.
|
19
|
+
*/
|
20
|
+
|
21
|
+
/* used to remove borders from tables and images */
|
22
|
+
.borderless, table.borderless td, table.borderless th {
|
23
|
+
border: 0 }
|
24
|
+
|
25
|
+
table.borderless td, table.borderless th {
|
26
|
+
/* Override padding for "table.docutils td" with "! important".
|
27
|
+
The right padding separates the table cells. */
|
28
|
+
padding: 0 0.5em 0 0 ! important }
|
29
|
+
|
30
|
+
.first {
|
31
|
+
/* Override more specific margin styles with "! important". */
|
32
|
+
margin-top: 0 ! important }
|
33
|
+
|
34
|
+
.last, .with-subtitle {
|
35
|
+
margin-bottom: 0 ! important }
|
36
|
+
|
37
|
+
.hidden {
|
38
|
+
display: none }
|
39
|
+
|
40
|
+
.subscript {
|
41
|
+
vertical-align: sub;
|
42
|
+
font-size: smaller }
|
43
|
+
|
44
|
+
.superscript {
|
45
|
+
vertical-align: super;
|
46
|
+
font-size: smaller }
|
47
|
+
|
48
|
+
a.toc-backref {
|
49
|
+
text-decoration: none ;
|
50
|
+
color: black }
|
51
|
+
|
52
|
+
blockquote.epigraph {
|
53
|
+
margin: 2em 5em ; }
|
54
|
+
|
55
|
+
dl.docutils dd {
|
56
|
+
margin-bottom: 0.5em }
|
57
|
+
|
58
|
+
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
59
|
+
overflow: hidden;
|
60
|
+
}
|
61
|
+
|
62
|
+
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
63
|
+
dl.docutils dt {
|
64
|
+
font-weight: bold }
|
65
|
+
*/
|
66
|
+
|
67
|
+
div.abstract {
|
68
|
+
margin: 2em 5em }
|
69
|
+
|
70
|
+
div.abstract p.topic-title {
|
71
|
+
font-weight: bold ;
|
72
|
+
text-align: center }
|
73
|
+
|
74
|
+
div.admonition, div.attention, div.caution, div.danger, div.error,
|
75
|
+
div.hint, div.important, div.note, div.tip, div.warning {
|
76
|
+
margin: 2em ;
|
77
|
+
border: medium outset ;
|
78
|
+
padding: 1em }
|
79
|
+
|
80
|
+
div.admonition p.admonition-title, div.hint p.admonition-title,
|
81
|
+
div.important p.admonition-title, div.note p.admonition-title,
|
82
|
+
div.tip p.admonition-title {
|
83
|
+
font-weight: bold ;
|
84
|
+
font-family: sans-serif }
|
85
|
+
|
86
|
+
div.attention p.admonition-title, div.caution p.admonition-title,
|
87
|
+
div.danger p.admonition-title, div.error p.admonition-title,
|
88
|
+
div.warning p.admonition-title, .code .error {
|
89
|
+
color: red ;
|
90
|
+
font-weight: bold ;
|
91
|
+
font-family: sans-serif }
|
92
|
+
|
93
|
+
/* Uncomment (and remove this text!) to get reduced vertical space in
|
94
|
+
compound paragraphs.
|
95
|
+
div.compound .compound-first, div.compound .compound-middle {
|
96
|
+
margin-bottom: 0.5em }
|
97
|
+
|
98
|
+
div.compound .compound-last, div.compound .compound-middle {
|
99
|
+
margin-top: 0.5em }
|
100
|
+
*/
|
101
|
+
|
102
|
+
div.dedication {
|
103
|
+
margin: 2em 5em ;
|
104
|
+
text-align: center ;
|
105
|
+
font-style: italic }
|
106
|
+
|
107
|
+
div.dedication p.topic-title {
|
108
|
+
font-weight: bold ;
|
109
|
+
font-style: normal }
|
110
|
+
|
111
|
+
div.figure {
|
112
|
+
margin-left: 2em ;
|
113
|
+
margin-right: 2em }
|
114
|
+
|
115
|
+
div.footer, div.header {
|
116
|
+
clear: both;
|
117
|
+
font-size: smaller }
|
118
|
+
|
119
|
+
div.line-block {
|
120
|
+
display: block ;
|
121
|
+
margin-top: 1em ;
|
122
|
+
margin-bottom: 1em }
|
123
|
+
|
124
|
+
div.line-block div.line-block {
|
125
|
+
margin-top: 0 ;
|
126
|
+
margin-bottom: 0 ;
|
127
|
+
margin-left: 1.5em }
|
128
|
+
|
129
|
+
div.sidebar {
|
130
|
+
margin: 0 0 0.5em 1em ;
|
131
|
+
border: medium outset ;
|
132
|
+
padding: 1em ;
|
133
|
+
background-color: #ffffee ;
|
134
|
+
width: 40% ;
|
135
|
+
float: right ;
|
136
|
+
clear: right }
|
137
|
+
|
138
|
+
div.sidebar p.rubric {
|
139
|
+
font-family: sans-serif ;
|
140
|
+
font-size: medium }
|
141
|
+
|
142
|
+
div.system-messages {
|
143
|
+
margin: 5em }
|
144
|
+
|
145
|
+
div.system-messages h1 {
|
146
|
+
color: red }
|
147
|
+
|
148
|
+
div.system-message {
|
149
|
+
border: medium outset ;
|
150
|
+
padding: 1em }
|
151
|
+
|
152
|
+
div.system-message p.system-message-title {
|
153
|
+
color: red ;
|
154
|
+
font-weight: bold }
|
155
|
+
|
156
|
+
div.topic {
|
157
|
+
margin: 2em }
|
158
|
+
|
159
|
+
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
160
|
+
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
161
|
+
margin-top: 0.4em }
|
162
|
+
|
163
|
+
h1.title {
|
164
|
+
text-align: center }
|
165
|
+
|
166
|
+
h2.subtitle {
|
167
|
+
text-align: center }
|
168
|
+
|
169
|
+
hr.docutils {
|
170
|
+
width: 75% }
|
171
|
+
|
172
|
+
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
173
|
+
clear: left ;
|
174
|
+
float: left ;
|
175
|
+
margin-right: 1em }
|
176
|
+
|
177
|
+
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
178
|
+
clear: right ;
|
179
|
+
float: right ;
|
180
|
+
margin-left: 1em }
|
181
|
+
|
182
|
+
img.align-center, .figure.align-center, object.align-center {
|
183
|
+
display: block;
|
184
|
+
margin-left: auto;
|
185
|
+
margin-right: auto;
|
186
|
+
}
|
187
|
+
|
188
|
+
table.align-center {
|
189
|
+
margin-left: auto;
|
190
|
+
margin-right: auto;
|
191
|
+
}
|
192
|
+
|
193
|
+
.align-left {
|
194
|
+
text-align: left }
|
195
|
+
|
196
|
+
.align-center {
|
197
|
+
clear: both ;
|
198
|
+
text-align: center }
|
199
|
+
|
200
|
+
.align-right {
|
201
|
+
text-align: right }
|
202
|
+
|
203
|
+
/* reset inner alignment in figures */
|
204
|
+
div.align-right {
|
205
|
+
text-align: inherit }
|
206
|
+
|
207
|
+
/* div.align-center * { */
|
208
|
+
/* text-align: left } */
|
209
|
+
|
210
|
+
.align-top {
|
211
|
+
vertical-align: top }
|
212
|
+
|
213
|
+
.align-middle {
|
214
|
+
vertical-align: middle }
|
215
|
+
|
216
|
+
.align-bottom {
|
217
|
+
vertical-align: bottom }
|
218
|
+
|
219
|
+
ol.simple, ul.simple {
|
220
|
+
margin-bottom: 1em }
|
221
|
+
|
222
|
+
ol.arabic {
|
223
|
+
list-style: decimal }
|
224
|
+
|
225
|
+
ol.loweralpha {
|
226
|
+
list-style: lower-alpha }
|
227
|
+
|
228
|
+
ol.upperalpha {
|
229
|
+
list-style: upper-alpha }
|
230
|
+
|
231
|
+
ol.lowerroman {
|
232
|
+
list-style: lower-roman }
|
233
|
+
|
234
|
+
ol.upperroman {
|
235
|
+
list-style: upper-roman }
|
236
|
+
|
237
|
+
p.attribution {
|
238
|
+
text-align: right ;
|
239
|
+
margin-left: 50% }
|
240
|
+
|
241
|
+
p.caption {
|
242
|
+
font-style: italic }
|
243
|
+
|
244
|
+
p.credits {
|
245
|
+
font-style: italic ;
|
246
|
+
font-size: smaller }
|
247
|
+
|
248
|
+
p.label {
|
249
|
+
white-space: nowrap }
|
250
|
+
|
251
|
+
p.rubric {
|
252
|
+
font-weight: bold ;
|
253
|
+
font-size: larger ;
|
254
|
+
color: maroon ;
|
255
|
+
text-align: center }
|
256
|
+
|
257
|
+
p.sidebar-title {
|
258
|
+
font-family: sans-serif ;
|
259
|
+
font-weight: bold ;
|
260
|
+
font-size: larger }
|
261
|
+
|
262
|
+
p.sidebar-subtitle {
|
263
|
+
font-family: sans-serif ;
|
264
|
+
font-weight: bold }
|
265
|
+
|
266
|
+
p.topic-title {
|
267
|
+
font-weight: bold }
|
268
|
+
|
269
|
+
pre.address {
|
270
|
+
margin-bottom: 0 ;
|
271
|
+
margin-top: 0 ;
|
272
|
+
font: inherit }
|
273
|
+
|
274
|
+
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
275
|
+
margin-left: 2em ;
|
276
|
+
margin-right: 2em }
|
277
|
+
|
278
|
+
pre.code .ln { color: gray; } /* line numbers */
|
279
|
+
pre.code, code { background-color: #eeeeee }
|
280
|
+
pre.code .comment, code .comment { color: #5C6576 }
|
281
|
+
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
282
|
+
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
283
|
+
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
284
|
+
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
285
|
+
pre.code .inserted, code .inserted { background-color: #A3D289}
|
286
|
+
|
287
|
+
span.classifier {
|
288
|
+
font-family: sans-serif ;
|
289
|
+
font-style: oblique }
|
290
|
+
|
291
|
+
span.classifier-delimiter {
|
292
|
+
font-family: sans-serif ;
|
293
|
+
font-weight: bold }
|
294
|
+
|
295
|
+
span.interpreted {
|
296
|
+
font-family: sans-serif }
|
297
|
+
|
298
|
+
span.option {
|
299
|
+
white-space: nowrap }
|
300
|
+
|
301
|
+
span.pre {
|
302
|
+
white-space: pre }
|
303
|
+
|
304
|
+
span.problematic, pre.problematic {
|
305
|
+
color: red }
|
306
|
+
|
307
|
+
span.section-subtitle {
|
308
|
+
/* font-size relative to parent (h1..h6 element) */
|
309
|
+
font-size: 80% }
|
310
|
+
|
311
|
+
table.citation {
|
312
|
+
border-left: solid 1px gray;
|
313
|
+
margin-left: 1px }
|
314
|
+
|
315
|
+
table.docinfo {
|
316
|
+
margin: 2em 4em }
|
317
|
+
|
318
|
+
table.docutils {
|
319
|
+
margin-top: 0.5em ;
|
320
|
+
margin-bottom: 0.5em }
|
321
|
+
|
322
|
+
table.footnote {
|
323
|
+
border-left: solid 1px black;
|
324
|
+
margin-left: 1px }
|
325
|
+
|
326
|
+
table.docutils td, table.docutils th,
|
327
|
+
table.docinfo td, table.docinfo th {
|
328
|
+
padding-left: 0.5em ;
|
329
|
+
padding-right: 0.5em ;
|
330
|
+
vertical-align: top }
|
331
|
+
|
332
|
+
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
333
|
+
font-weight: bold ;
|
334
|
+
text-align: left ;
|
335
|
+
white-space: nowrap ;
|
336
|
+
padding-left: 0 }
|
337
|
+
|
338
|
+
/* "booktabs" style (no vertical lines) */
|
339
|
+
table.docutils.booktabs {
|
340
|
+
border: 0px;
|
341
|
+
border-top: 2px solid;
|
342
|
+
border-bottom: 2px solid;
|
343
|
+
border-collapse: collapse;
|
344
|
+
}
|
345
|
+
table.docutils.booktabs * {
|
346
|
+
border: 0px;
|
347
|
+
}
|
348
|
+
table.docutils.booktabs th {
|
349
|
+
border-bottom: thin solid;
|
350
|
+
text-align: left;
|
351
|
+
}
|
352
|
+
|
353
|
+
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
354
|
+
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
355
|
+
font-size: 100% }
|
356
|
+
|
357
|
+
ul.auto-toc {
|
358
|
+
list-style-type: none }
|
359
|
+
|
360
|
+
</style>
|
361
|
+
</head>
|
362
|
+
<body>
|
363
|
+
<div class="document" id="analytic-distributions-restriction-per-hr-department">
|
364
|
+
<h1 class="title">Analytic distributions restriction per HR department</h1>
|
365
|
+
|
366
|
+
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
367
|
+
!! This file is generated by oca-gen-addon-readme !!
|
368
|
+
!! changes will be overwritten. !!
|
369
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
370
|
+
!! source digest: sha256:e787f119827c6a3cd07a0d80cd200c9f1aea5dc339e7ef2fa58277891f410915
|
371
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
372
|
+
<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/account-analytic/tree/16.0/analytic_hr_department_restriction"><img alt="OCA/account-analytic" src="https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/account-analytic-16-0/account-analytic-16-0-analytic_hr_department_restriction"><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/account-analytic&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
373
|
+
<p>This module allows you to limit plans and analytical accounts by employee departments.</p>
|
374
|
+
<p>Users will only be able to view plans and analytical accounts linked to their employee’s department or those with no department defined.</p>
|
375
|
+
<p>Users with the “Invoicing / Billing” permission will be able to view all plans and analytical accounts without restrictions.</p>
|
376
|
+
<p><strong>Table of contents</strong></p>
|
377
|
+
<div class="contents local topic" id="contents">
|
378
|
+
<ul class="simple">
|
379
|
+
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
|
380
|
+
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
|
381
|
+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
|
382
|
+
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
|
383
|
+
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
|
384
|
+
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
|
385
|
+
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
|
386
|
+
</ul>
|
387
|
+
</li>
|
388
|
+
</ul>
|
389
|
+
</div>
|
390
|
+
<div class="section" id="configuration">
|
391
|
+
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
|
392
|
+
<ul class="simple">
|
393
|
+
<li>Your user must have the “Analytic Accounting” permission.</li>
|
394
|
+
<li>Create an employee linked to your user with a defined department.</li>
|
395
|
+
</ul>
|
396
|
+
</div>
|
397
|
+
<div class="section" id="usage">
|
398
|
+
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
|
399
|
+
<ol class="arabic simple">
|
400
|
+
<li>Go to an analytical plan/account and define your employee’s department.</li>
|
401
|
+
<li>Go to an analytical plan/account and define a different department than your employee’s department.</li>
|
402
|
+
<li>Go to an analytical plan/account and leave the department empty.</li>
|
403
|
+
<li>Users without the “Invoicing / Billing” permission will be able to see only the plans/analytical accounts of the user’s employee’s department.</li>
|
404
|
+
<li>Users with the “Analytic Accounting (without department)” will be able to view the plans/analytical accounts without a department, as will users with the permission “Invoicing / Billing”.</li>
|
405
|
+
</ol>
|
406
|
+
</div>
|
407
|
+
<div class="section" id="bug-tracker">
|
408
|
+
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
|
409
|
+
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-analytic/issues">GitHub Issues</a>.
|
410
|
+
In case of trouble, please check there if your issue has already been reported.
|
411
|
+
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
412
|
+
<a class="reference external" href="https://github.com/OCA/account-analytic/issues/new?body=module:%20analytic_hr_department_restriction%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
413
|
+
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
414
|
+
</div>
|
415
|
+
<div class="section" id="credits">
|
416
|
+
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
|
417
|
+
<div class="section" id="authors">
|
418
|
+
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
|
419
|
+
<ul class="simple">
|
420
|
+
<li>Tecnativa</li>
|
421
|
+
</ul>
|
422
|
+
</div>
|
423
|
+
<div class="section" id="contributors">
|
424
|
+
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
|
425
|
+
<ul class="simple">
|
426
|
+
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
427
|
+
<li>Víctor Martínez</li>
|
428
|
+
<li>Pedro M. Baeza</li>
|
429
|
+
</ul>
|
430
|
+
</li>
|
431
|
+
</ul>
|
432
|
+
</div>
|
433
|
+
<div class="section" id="maintainers">
|
434
|
+
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
|
435
|
+
<p>This module is maintained by the OCA.</p>
|
436
|
+
<a class="reference external image-reference" href="https://odoo-community.org">
|
437
|
+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
438
|
+
</a>
|
439
|
+
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
440
|
+
mission is to support the collaborative development of Odoo features and
|
441
|
+
promote its widespread use.</p>
|
442
|
+
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
443
|
+
<p><a class="reference external image-reference" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
|
444
|
+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-analytic/tree/16.0/analytic_hr_department_restriction">OCA/account-analytic</a> project on GitHub.</p>
|
445
|
+
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
446
|
+
</div>
|
447
|
+
</div>
|
448
|
+
</div>
|
449
|
+
</body>
|
450
|
+
</html>
|
odoo/addons/analytic_hr_department_restriction/tests/test_analytic_hr_department_restriction.py
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
# Copyright 2025 Tecnativa - Víctor Martínez
|
2
|
+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
3
|
+
from odoo.tests import new_test_user
|
4
|
+
from odoo.tests.common import users
|
5
|
+
|
6
|
+
from odoo.addons.base.tests.common import BaseCommon
|
7
|
+
|
8
|
+
|
9
|
+
class TestAnalyticHrDepartmentRestriction(BaseCommon):
|
10
|
+
@classmethod
|
11
|
+
def setUpClass(cls):
|
12
|
+
super().setUpClass()
|
13
|
+
cls.env = cls.env(
|
14
|
+
context=dict(
|
15
|
+
cls.env.context,
|
16
|
+
test_analytic_hr_department_restriction=True,
|
17
|
+
)
|
18
|
+
)
|
19
|
+
cls.department_a = cls.env["hr.department"].create(
|
20
|
+
{
|
21
|
+
"name": "Test department A",
|
22
|
+
"company_id": cls.env.company.id,
|
23
|
+
}
|
24
|
+
)
|
25
|
+
cls.department_b = cls.env["hr.department"].create(
|
26
|
+
{
|
27
|
+
"name": "Test department B",
|
28
|
+
"company_id": False,
|
29
|
+
}
|
30
|
+
)
|
31
|
+
cls.basic_user = new_test_user(cls.env, login="test-basic_user")
|
32
|
+
cls.env["hr.employee"].create(
|
33
|
+
{
|
34
|
+
"name": "Test employee Basic",
|
35
|
+
"user_id": cls.basic_user.id,
|
36
|
+
"department_id": cls.department_a.id,
|
37
|
+
}
|
38
|
+
)
|
39
|
+
cls.user = new_test_user(
|
40
|
+
cls.env,
|
41
|
+
login="test-user",
|
42
|
+
groups="base.group_user,analytic.group_analytic_accounting",
|
43
|
+
)
|
44
|
+
cls.env["hr.employee"].create(
|
45
|
+
{
|
46
|
+
"name": "Test employee A",
|
47
|
+
"user_id": cls.user.id,
|
48
|
+
"department_id": cls.department_a.id,
|
49
|
+
}
|
50
|
+
)
|
51
|
+
cls.user_extra = new_test_user(
|
52
|
+
cls.env,
|
53
|
+
login="test-user_extra",
|
54
|
+
groups="base.group_user,analytic_hr_department_restriction.group_analytic_accounting_without_department", # noqa: B950
|
55
|
+
)
|
56
|
+
cls.env["hr.employee"].create(
|
57
|
+
{
|
58
|
+
"name": "Test employee A extra",
|
59
|
+
"user_id": cls.user_extra.id,
|
60
|
+
"department_id": cls.department_a.id,
|
61
|
+
}
|
62
|
+
)
|
63
|
+
cls.manager = new_test_user(
|
64
|
+
cls.env,
|
65
|
+
login="test-manager",
|
66
|
+
groups="account.group_account_invoice,analytic.group_analytic_accounting",
|
67
|
+
)
|
68
|
+
cls.env["hr.employee"].create(
|
69
|
+
{
|
70
|
+
"name": "Test employee B",
|
71
|
+
"user_id": cls.manager.id,
|
72
|
+
"department_id": cls.department_b.id,
|
73
|
+
}
|
74
|
+
)
|
75
|
+
cls.plan_a = cls.env["account.analytic.plan"].create(
|
76
|
+
{
|
77
|
+
"name": "Test plan A",
|
78
|
+
"department_id": cls.department_a.id,
|
79
|
+
"company_id": cls.env.company.id,
|
80
|
+
}
|
81
|
+
)
|
82
|
+
cls.account_a = cls.env["account.analytic.account"].create(
|
83
|
+
{
|
84
|
+
"name": "Test account A",
|
85
|
+
"plan_id": cls.plan_a.id,
|
86
|
+
"department_id": cls.department_a.id,
|
87
|
+
"company_id": cls.env.company.id,
|
88
|
+
}
|
89
|
+
)
|
90
|
+
cls.plan_b = cls.env["account.analytic.plan"].create(
|
91
|
+
{
|
92
|
+
"name": "Test plan B",
|
93
|
+
"department_id": cls.department_b.id,
|
94
|
+
"company_id": cls.env.company.id,
|
95
|
+
}
|
96
|
+
)
|
97
|
+
cls.account_b = cls.env["account.analytic.account"].create(
|
98
|
+
{
|
99
|
+
"name": "Test account B",
|
100
|
+
"plan_id": cls.plan_b.id,
|
101
|
+
"department_id": cls.department_b.id,
|
102
|
+
"company_id": cls.env.company.id,
|
103
|
+
}
|
104
|
+
)
|
105
|
+
cls.plan_c = cls.env["account.analytic.plan"].create(
|
106
|
+
{
|
107
|
+
"name": "Test plan C",
|
108
|
+
"company_id": cls.env.company.id,
|
109
|
+
}
|
110
|
+
)
|
111
|
+
cls.account_c = cls.env["account.analytic.account"].create(
|
112
|
+
{
|
113
|
+
"name": "Test account C",
|
114
|
+
"plan_id": cls.plan_c.id,
|
115
|
+
"company_id": cls.env.company.id,
|
116
|
+
}
|
117
|
+
)
|
118
|
+
|
119
|
+
@users("test-basic_user")
|
120
|
+
def test_analytic_data_basic_user(self):
|
121
|
+
accounts = self.env["account.analytic.account"].search([])
|
122
|
+
self.assertNotIn(self.account_a, accounts)
|
123
|
+
self.assertNotIn(self.account_b, accounts)
|
124
|
+
self.assertNotIn(self.account_c, accounts)
|
125
|
+
|
126
|
+
@users("test-user")
|
127
|
+
def test_analytic_data_user(self):
|
128
|
+
plans = self.env["account.analytic.plan"].search([])
|
129
|
+
self.assertIn(self.plan_a, plans)
|
130
|
+
self.assertNotIn(self.plan_b, plans)
|
131
|
+
self.assertNotIn(self.plan_c, plans)
|
132
|
+
accounts = self.env["account.analytic.account"].search([])
|
133
|
+
self.assertIn(self.account_a, accounts)
|
134
|
+
self.assertNotIn(self.account_b, accounts)
|
135
|
+
self.assertNotIn(self.account_c, accounts)
|
136
|
+
|
137
|
+
@users("test-user_extra")
|
138
|
+
def test_analytic_data_user_extra(self):
|
139
|
+
plans = self.env["account.analytic.plan"].search([])
|
140
|
+
self.assertIn(self.plan_a, plans)
|
141
|
+
self.assertNotIn(self.plan_b, plans)
|
142
|
+
self.assertIn(self.plan_c, plans)
|
143
|
+
accounts = self.env["account.analytic.account"].search([])
|
144
|
+
self.assertIn(self.account_a, accounts)
|
145
|
+
self.assertNotIn(self.account_b, accounts)
|
146
|
+
self.assertIn(self.account_c, accounts)
|
147
|
+
|
148
|
+
@users("test-manager")
|
149
|
+
def test_analytic_data_manager(self):
|
150
|
+
plans = self.env["account.analytic.plan"].search([])
|
151
|
+
self.assertIn(self.plan_a, plans)
|
152
|
+
self.assertIn(self.plan_b, plans)
|
153
|
+
self.assertIn(self.plan_c, plans)
|
154
|
+
accounts = self.env["account.analytic.account"].search([])
|
155
|
+
self.assertIn(self.account_a, accounts)
|
156
|
+
self.assertIn(self.account_b, accounts)
|
157
|
+
self.assertIn(self.account_c, accounts)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<odoo>
|
3
|
+
<record id="view_account_analytic_account_form" model="ir.ui.view">
|
4
|
+
<field name="model">account.analytic.account</field>
|
5
|
+
<field name="inherit_id" ref="analytic.view_account_analytic_account_form" />
|
6
|
+
<field name="arch" type="xml">
|
7
|
+
<field name="plan_id" position="before">
|
8
|
+
<field name="department_id" groups="account.group_account_invoice" />
|
9
|
+
</field>
|
10
|
+
</field>
|
11
|
+
</record>
|
12
|
+
<record id="view_account_analytic_account_list" model="ir.ui.view">
|
13
|
+
<field name="model">account.analytic.account</field>
|
14
|
+
<field name="inherit_id" ref="analytic.view_account_analytic_account_list" />
|
15
|
+
<field name="arch" type="xml">
|
16
|
+
<field name="plan_id" position="after">
|
17
|
+
<field
|
18
|
+
name="department_id"
|
19
|
+
groups="account.group_account_invoice"
|
20
|
+
optional="hide"
|
21
|
+
/>
|
22
|
+
</field>
|
23
|
+
</field>
|
24
|
+
</record>
|
25
|
+
<record id="view_account_analytic_account_search" model="ir.ui.view">
|
26
|
+
<field name="model">account.analytic.account</field>
|
27
|
+
<field name="inherit_id" ref="analytic.view_account_analytic_account_search" />
|
28
|
+
<field name="arch" type="xml">
|
29
|
+
<field name="partner_id" position="after">
|
30
|
+
<field name="department_id" groups="account.group_account_invoice" />
|
31
|
+
</field>
|
32
|
+
<filter name="associatedpartner" position="after">
|
33
|
+
<filter
|
34
|
+
string="Department"
|
35
|
+
name="filter_department_id"
|
36
|
+
domain="[]"
|
37
|
+
context="{'group_by': 'department_id'}"
|
38
|
+
groups="account.group_account_invoice"
|
39
|
+
/>
|
40
|
+
</filter>
|
41
|
+
</field>
|
42
|
+
</record>
|
43
|
+
</odoo>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<odoo>
|
3
|
+
<record id="account_analytic_plan_form_view" model="ir.ui.view">
|
4
|
+
<field name="model">account.analytic.plan</field>
|
5
|
+
<field name="inherit_id" ref="analytic.account_analytic_plan_form_view" />
|
6
|
+
<field name="arch" type="xml">
|
7
|
+
<xpath expr="//group//field[@name='company_id']" position="before">
|
8
|
+
<field name="department_id" groups="account.group_account_invoice" />
|
9
|
+
</xpath>
|
10
|
+
</field>
|
11
|
+
</record>
|
12
|
+
<record id="account_analytic_plan_tree_view" model="ir.ui.view">
|
13
|
+
<field name="model">account.analytic.plan</field>
|
14
|
+
<field name="inherit_id" ref="analytic.account_analytic_plan_tree_view" />
|
15
|
+
<field name="arch" type="xml">
|
16
|
+
<field name="company_id" position="before">
|
17
|
+
<field
|
18
|
+
name="company_id"
|
19
|
+
invisible="1"
|
20
|
+
groups="!base.group_multi_company"
|
21
|
+
/>
|
22
|
+
<field
|
23
|
+
name="department_id"
|
24
|
+
groups="account.group_account_invoice"
|
25
|
+
optional="hide"
|
26
|
+
/>
|
27
|
+
</field>
|
28
|
+
</field>
|
29
|
+
</record>
|
30
|
+
</odoo>
|
@@ -0,0 +1,121 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: odoo-addon-analytic_hr_department_restriction
|
3
|
+
Version: 16.0.1.0.0.2
|
4
|
+
Summary: Analytic distributions restriction per HR department
|
5
|
+
Home-page: https://github.com/OCA/account-analytic
|
6
|
+
Author: Tecnativa, Odoo Community Association (OCA)
|
7
|
+
Author-email: support@odoo-community.org
|
8
|
+
License: AGPL-3
|
9
|
+
Classifier: Programming Language :: Python
|
10
|
+
Classifier: Framework :: Odoo
|
11
|
+
Classifier: Framework :: Odoo :: 16.0
|
12
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
13
|
+
Requires-Python: >=3.10
|
14
|
+
Requires-Dist: odoo<16.1dev,>=16.0a
|
15
|
+
|
16
|
+
====================================================
|
17
|
+
Analytic distributions restriction per HR department
|
18
|
+
====================================================
|
19
|
+
|
20
|
+
..
|
21
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
22
|
+
!! This file is generated by oca-gen-addon-readme !!
|
23
|
+
!! changes will be overwritten. !!
|
24
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
25
|
+
!! source digest: sha256:e787f119827c6a3cd07a0d80cd200c9f1aea5dc339e7ef2fa58277891f410915
|
26
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
27
|
+
|
28
|
+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
29
|
+
:target: https://odoo-community.org/page/development-status
|
30
|
+
:alt: Beta
|
31
|
+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
32
|
+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
33
|
+
:alt: License: AGPL-3
|
34
|
+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
|
35
|
+
:target: https://github.com/OCA/account-analytic/tree/16.0/analytic_hr_department_restriction
|
36
|
+
:alt: OCA/account-analytic
|
37
|
+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
38
|
+
:target: https://translation.odoo-community.org/projects/account-analytic-16-0/account-analytic-16-0-analytic_hr_department_restriction
|
39
|
+
:alt: Translate me on Weblate
|
40
|
+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
41
|
+
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-analytic&target_branch=16.0
|
42
|
+
:alt: Try me on Runboat
|
43
|
+
|
44
|
+
|badge1| |badge2| |badge3| |badge4| |badge5|
|
45
|
+
|
46
|
+
This module allows you to limit plans and analytical accounts by employee departments.
|
47
|
+
|
48
|
+
Users will only be able to view plans and analytical accounts linked to their employee's department or those with no department defined.
|
49
|
+
|
50
|
+
Users with the "Invoicing / Billing" permission will be able to view all plans and analytical accounts without restrictions.
|
51
|
+
|
52
|
+
**Table of contents**
|
53
|
+
|
54
|
+
.. contents::
|
55
|
+
:local:
|
56
|
+
|
57
|
+
Configuration
|
58
|
+
=============
|
59
|
+
|
60
|
+
- Your user must have the "Analytic Accounting" permission.
|
61
|
+
- Create an employee linked to your user with a defined department.
|
62
|
+
|
63
|
+
Usage
|
64
|
+
=====
|
65
|
+
|
66
|
+
#. Go to an analytical plan/account and define your employee's department.
|
67
|
+
#. Go to an analytical plan/account and define a different department than your employee's department.
|
68
|
+
#. Go to an analytical plan/account and leave the department empty.
|
69
|
+
#. Users without the "Invoicing / Billing" permission will be able to see only the plans/analytical accounts of the user's employee's department.
|
70
|
+
#. Users with the "Analytic Accounting (without department)" will be able to view the plans/analytical accounts without a department, as will users with the permission "Invoicing / Billing".
|
71
|
+
|
72
|
+
Bug Tracker
|
73
|
+
===========
|
74
|
+
|
75
|
+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/issues>`_.
|
76
|
+
In case of trouble, please check there if your issue has already been reported.
|
77
|
+
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
78
|
+
`feedback <https://github.com/OCA/account-analytic/issues/new?body=module:%20analytic_hr_department_restriction%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
79
|
+
|
80
|
+
Do not contact contributors directly about support or help with technical issues.
|
81
|
+
|
82
|
+
Credits
|
83
|
+
=======
|
84
|
+
|
85
|
+
Authors
|
86
|
+
~~~~~~~
|
87
|
+
|
88
|
+
* Tecnativa
|
89
|
+
|
90
|
+
Contributors
|
91
|
+
~~~~~~~~~~~~
|
92
|
+
|
93
|
+
* `Tecnativa <https://www.tecnativa.com>`__:
|
94
|
+
|
95
|
+
* Víctor Martínez
|
96
|
+
* Pedro M. Baeza
|
97
|
+
|
98
|
+
Maintainers
|
99
|
+
~~~~~~~~~~~
|
100
|
+
|
101
|
+
This module is maintained by the OCA.
|
102
|
+
|
103
|
+
.. image:: https://odoo-community.org/logo.png
|
104
|
+
:alt: Odoo Community Association
|
105
|
+
:target: https://odoo-community.org
|
106
|
+
|
107
|
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
108
|
+
mission is to support the collaborative development of Odoo features and
|
109
|
+
promote its widespread use.
|
110
|
+
|
111
|
+
.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
|
112
|
+
:target: https://github.com/victoralmau
|
113
|
+
:alt: victoralmau
|
114
|
+
|
115
|
+
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
116
|
+
|
117
|
+
|maintainer-victoralmau|
|
118
|
+
|
119
|
+
This module is part of the `OCA/account-analytic <https://github.com/OCA/account-analytic/tree/16.0/analytic_hr_department_restriction>`_ project on GitHub.
|
120
|
+
|
121
|
+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
odoo/addons/analytic_hr_department_restriction/README.rst,sha256=rwxO2EtgDxTrK_v-Yqn7hescD-eIm6PPUGQVrxPrKU0,4382
|
2
|
+
odoo/addons/analytic_hr_department_restriction/__init__.py,sha256=X9EJGOE2GtZbS0G82PtSXmWSZ_R8jEM0rlJTDliQjp4,21
|
3
|
+
odoo/addons/analytic_hr_department_restriction/__manifest__.py,sha256=xizPVX4FDKNtyhENV4mt77_zzaL7XLq4M40GBOSRQlo,632
|
4
|
+
odoo/addons/analytic_hr_department_restriction/i18n/analytic_hr_department_restriction.pot,sha256=IVLgb5OOVyJJuK_w6GaMb72G1VnYFpQp7hyh-VGHHf0,1505
|
5
|
+
odoo/addons/analytic_hr_department_restriction/i18n/es.po,sha256=-sGYwxp6Pc6sIlZwbM3uJHCCXXeoC55sw9HzYJDgQ5A,1585
|
6
|
+
odoo/addons/analytic_hr_department_restriction/models/__init__.py,sha256=Dd5CV80qJ4N-DNWSSLVB8_1O4g52NI1BcAD6dKUZ8C8,162
|
7
|
+
odoo/addons/analytic_hr_department_restriction/models/account_analytic_account.py,sha256=OJz2W0lwN_2-i8Ray_gNkM9aH_kQ6g8_nNzdLmCm1Vs,428
|
8
|
+
odoo/addons/analytic_hr_department_restriction/models/account_analytic_plan.py,sha256=p_K0Texwdf1-RqCLHD9p-qyWwhCkbzuJo_j_16Js5ZE,422
|
9
|
+
odoo/addons/analytic_hr_department_restriction/models/ir_rule.py,sha256=LGnrCIQY3u_Lks0tIuGXl3GJ5hj3xxdf76h9Hfkoi9I,1989
|
10
|
+
odoo/addons/analytic_hr_department_restriction/readme/CONFIGURE.rst,sha256=cZJpECvRUAD5PNOUOjGkPLXpd2rBkoHEk63OSOjpwKY,127
|
11
|
+
odoo/addons/analytic_hr_department_restriction/readme/CONTRIBUTORS.rst,sha256=A-ePkWzxL7sfk2futLXfYllbnSRrZzTeeJCNg_snLDo,86
|
12
|
+
odoo/addons/analytic_hr_department_restriction/readme/DESCRIPTION.rst,sha256=_AIO2kymt1cEs5uL-oPiUw7Qs_bCuSSluW6QmWLOs3I,350
|
13
|
+
odoo/addons/analytic_hr_department_restriction/readme/USAGE.rst,sha256=YBFF35tDh8dViMdrwn_p7TZ9WK1mHIX544mxR9cov0Q,582
|
14
|
+
odoo/addons/analytic_hr_department_restriction/security/groups.xml,sha256=dN536AJfIOSRjUafmSvWpYGpqTV5no6DlLrh682yrug,423
|
15
|
+
odoo/addons/analytic_hr_department_restriction/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
|
16
|
+
odoo/addons/analytic_hr_department_restriction/static/description/index.html,sha256=ObBcb4M4IojYHiSVzJvCpSWeLNrVi4MaNJU7XzNeMTE,14199
|
17
|
+
odoo/addons/analytic_hr_department_restriction/tests/__init__.py,sha256=l6JUuT5fLrb_xYWQW-GbLXl7g0cQ3sBAdRxC5EsP8Aw,166
|
18
|
+
odoo/addons/analytic_hr_department_restriction/tests/test_analytic_hr_department_restriction.py,sha256=12ZPEwm26Z116IhqHdvvHsEN1rNOjBT17u8inWA4QM0,5684
|
19
|
+
odoo/addons/analytic_hr_department_restriction/views/account_analytic_account_views.xml,sha256=IY6E8D5r5o4drFmOqaDq_tqnoFpzVSDT638AVUiq-98,1866
|
20
|
+
odoo/addons/analytic_hr_department_restriction/views/account_analytic_plan_views.xml,sha256=wqfrwdIDyXJZTDpZdxhiUYFEo--sQeDrTKxHZu7UbD4,1226
|
21
|
+
odoo_addon_analytic_hr_department_restriction-16.0.1.0.0.2.dist-info/METADATA,sha256=6tbj2oN-dUNW4nbI4V02XX9KIQwxLdBSuzotZRK0RAY,4948
|
22
|
+
odoo_addon_analytic_hr_department_restriction-16.0.1.0.0.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
23
|
+
odoo_addon_analytic_hr_department_restriction-16.0.1.0.0.2.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
|
24
|
+
odoo_addon_analytic_hr_department_restriction-16.0.1.0.0.2.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
odoo
|