mirror of
https://github.com/bringout/oca-financial.git
synced 2026-04-22 21:02:03 +02:00
Initial commit: OCA Financial packages (186 packages)
This commit is contained in:
commit
3e0e8473fb
8757 changed files with 947473 additions and 0 deletions
|
|
@ -0,0 +1,45 @@
|
|||
# Analytic distributions restriction per HR department
|
||||
|
||||
Odoo addon: analytic_hr_department_restriction
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install odoo-bringout-oca-account-analytic-analytic_hr_department_restriction
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
This addon depends on:
|
||||
- account
|
||||
- hr
|
||||
|
||||
## Manifest Information
|
||||
|
||||
- **Name**: Analytic distributions restriction per HR department
|
||||
- **Version**: 16.0.1.1.0
|
||||
- **Category**: Account
|
||||
- **License**: AGPL-3
|
||||
- **Installable**: True
|
||||
|
||||
## Source
|
||||
|
||||
Based on [OCA/account-analytic](https://github.com/OCA/account-analytic) branch 16.0, addon `analytic_hr_department_restriction`.
|
||||
|
||||
## License
|
||||
|
||||
This package maintains the original AGPL-3 license from the upstream Odoo project.
|
||||
|
||||
## Documentation
|
||||
|
||||
- Overview: doc/OVERVIEW.md
|
||||
- Architecture: doc/ARCHITECTURE.md
|
||||
- Models: doc/MODELS.md
|
||||
- Controllers: doc/CONTROLLERS.md
|
||||
- Wizards: doc/WIZARDS.md
|
||||
- Install: doc/INSTALL.md
|
||||
- Usage: doc/USAGE.md
|
||||
- Configuration: doc/CONFIGURATION.md
|
||||
- Dependencies: doc/DEPENDENCIES.md
|
||||
- Troubleshooting: doc/TROUBLESHOOTING.md
|
||||
- FAQ: doc/FAQ.md
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
.. image:: https://odoo-community.org/readme-banner-image
|
||||
:target: https://odoo-community.org/get-involved?utm_source=readme
|
||||
:alt: Odoo Community Association
|
||||
|
||||
====================================================
|
||||
Analytic distributions restriction per HR department
|
||||
====================================================
|
||||
|
||||
..
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:df61994dd6701d3ad016addcdd3cbf0ce2dba05a1f1a27a949133ac0d164bb95
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/account-analytic/tree/16.0/analytic_hr_department_restriction
|
||||
:alt: OCA/account-analytic
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/account-analytic-16-0/account-analytic-16-0-analytic_hr_department_restriction
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
|
||||
:target: https://runboat.odoo-community.org/builds?repo=OCA/account-analytic&target_branch=16.0
|
||||
:alt: Try me on Runboat
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module allows you to limit plans and analytical accounts by employee departments.
|
||||
|
||||
Users will only be able to view plans and analytical accounts linked to their employee's department or those with no department defined.
|
||||
|
||||
Users with the "Invoicing / Billing" permission will be able to view all plans and analytical accounts without restrictions.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
- Your user must have the "Analytic Accounting" permission.
|
||||
- Create an employee linked to your user with a defined department.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
#. Go to an analytical plan/account and define your employee's department.
|
||||
#. Go to an analytical plan/account and define a different department than your employee's department.
|
||||
#. Go to an analytical plan/account and leave the department empty.
|
||||
#. Users without the "Invoicing / Billing" permission will be able to see only the plans/analytical accounts of the user's employee's department.
|
||||
#. 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".
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-analytic/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
`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**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Tecnativa
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* `Tecnativa <https://www.tecnativa.com>`__:
|
||||
|
||||
* Víctor Martínez
|
||||
* Pedro M. Baeza
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px
|
||||
:target: https://github.com/victoralmau
|
||||
:alt: victoralmau
|
||||
|
||||
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|
||||
|
||||
|maintainer-victoralmau|
|
||||
|
||||
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.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import models
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# Copyright 2025 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
{
|
||||
"name": "Analytic distributions restriction per HR department",
|
||||
"author": "Tecnativa, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/account-analytic",
|
||||
"version": "16.0.1.1.0",
|
||||
"depends": ["account", "hr"],
|
||||
"license": "AGPL-3",
|
||||
"category": "Account",
|
||||
"installable": True,
|
||||
"maintainers": ["victoralmau"],
|
||||
"data": [
|
||||
"security/groups.xml",
|
||||
"views/account_analytic_account_views.xml",
|
||||
"views/account_analytic_plan_views.xml",
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * analytic_hr_department_restriction
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_account
|
||||
msgid "Analytic Account"
|
||||
msgstr ""
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:res.groups,name:analytic_hr_department_restriction.group_analytic_accounting_without_department
|
||||
msgid "Analytic Accounting (without department)"
|
||||
msgstr ""
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_plan
|
||||
msgid "Analytic Plans"
|
||||
msgstr ""
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_account__department_ids
|
||||
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_plan__department_ids
|
||||
#: model_terms:ir.ui.view,arch_db:analytic_hr_department_restriction.view_account_analytic_account_search
|
||||
msgid "Departments"
|
||||
msgstr ""
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_ir_rule
|
||||
msgid "Record Rule"
|
||||
msgstr ""
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * analytic_hr_department_restriction
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_account
|
||||
msgid "Analytic Account"
|
||||
msgstr "Analitički konto"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:res.groups,name:analytic_hr_department_restriction.group_analytic_accounting_without_department
|
||||
msgid "Analytic Accounting (without department)"
|
||||
msgstr "Analitičko računovodstvo (bez odeljenja)"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_plan
|
||||
msgid "Analytic Plans"
|
||||
msgstr "Analitički plan"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_account__department_ids
|
||||
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_plan__department_ids
|
||||
#: model_terms:ir.ui.view,arch_db:analytic_hr_department_restriction.view_account_analytic_account_search
|
||||
msgid "Departments"
|
||||
msgstr "Odjeljenja"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_ir_rule
|
||||
msgid "Record Rule"
|
||||
msgstr "Pravilo zapisa"
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * analytic_hr_department_restriction
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-04-16 14:25+0000\n"
|
||||
"PO-Revision-Date: 2025-06-12 14:26+0000\n"
|
||||
"Last-Translator: Víctor Martínez <victor.martinez@tecnativa.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: es\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 5.10.4\n"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_account
|
||||
msgid "Analytic Account"
|
||||
msgstr "Cuenta analítica"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:res.groups,name:analytic_hr_department_restriction.group_analytic_accounting_without_department
|
||||
msgid "Analytic Accounting (without department)"
|
||||
msgstr "Contabilidad analítica (sin departamento)"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_plan
|
||||
msgid "Analytic Plans"
|
||||
msgstr "Planes analíticos"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_account__department_ids
|
||||
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_plan__department_ids
|
||||
#: model_terms:ir.ui.view,arch_db:analytic_hr_department_restriction.view_account_analytic_account_search
|
||||
msgid "Departments"
|
||||
msgstr "Departamentos"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_ir_rule
|
||||
msgid "Record Rule"
|
||||
msgstr ""
|
||||
|
||||
#~ msgid "Department"
|
||||
#~ msgstr "Departamento"
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * analytic_hr_department_restriction
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 16.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"PO-Revision-Date: 2025-06-16 08:26+0000\n"
|
||||
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: it\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 5.10.4\n"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_account
|
||||
msgid "Analytic Account"
|
||||
msgstr "Conto analitico"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:res.groups,name:analytic_hr_department_restriction.group_analytic_accounting_without_department
|
||||
msgid "Analytic Accounting (without department)"
|
||||
msgstr "Contabilità analitica (senza reparto)"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_account_analytic_plan
|
||||
msgid "Analytic Plans"
|
||||
msgstr "Piani analitici"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_account__department_ids
|
||||
#: model:ir.model.fields,field_description:analytic_hr_department_restriction.field_account_analytic_plan__department_ids
|
||||
#: model_terms:ir.ui.view,arch_db:analytic_hr_department_restriction.view_account_analytic_account_search
|
||||
msgid "Departments"
|
||||
msgstr "Reparti"
|
||||
|
||||
#. module: analytic_hr_department_restriction
|
||||
#: model:ir.model,name:analytic_hr_department_restriction.model_ir_rule
|
||||
msgid "Record Rule"
|
||||
msgstr "Regola su record"
|
||||
|
||||
#~ msgid "Department"
|
||||
#~ msgstr "Reparto"
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2025 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
from openupgradelib import openupgrade
|
||||
|
||||
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
openupgrade.m2o_to_x2m(
|
||||
env.cr,
|
||||
env["account.analytic.account"],
|
||||
"account_analytic_account",
|
||||
"department_ids",
|
||||
"department_id",
|
||||
)
|
||||
openupgrade.m2o_to_x2m(
|
||||
env.cr,
|
||||
env["account.analytic.plan"],
|
||||
"account_analytic_plan",
|
||||
"department_ids",
|
||||
"department_id",
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import account_analytic_account
|
||||
from . import account_analytic_plan
|
||||
from . import ir_rule
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Copyright 2025 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountAnalyticAccount(models.Model):
|
||||
_inherit = "account.analytic.account"
|
||||
|
||||
department_ids = fields.Many2many(
|
||||
comodel_name="hr.department",
|
||||
string="Departments",
|
||||
domain="['|',('company_id', '=?', company_id),('company_id', '=', False)]",
|
||||
)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Copyright 2025 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountAnalyticPlan(models.Model):
|
||||
_inherit = "account.analytic.plan"
|
||||
|
||||
department_ids = fields.Many2many(
|
||||
comodel_name="hr.department",
|
||||
string="Departments",
|
||||
domain="['|',('company_id', '=?', company_id),('company_id', '=', False)]",
|
||||
)
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
# Copyright 2025 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
||||
|
||||
from odoo import api, models, tools
|
||||
from odoo.osv import expression
|
||||
from odoo.tools import config
|
||||
|
||||
|
||||
class IrRule(models.Model):
|
||||
_inherit = "ir.rule"
|
||||
|
||||
@api.model
|
||||
@tools.conditional(
|
||||
"xml" not in config["dev_mode"],
|
||||
tools.ormcache(
|
||||
"self.env.uid",
|
||||
"self.env.su",
|
||||
"model_name",
|
||||
"mode",
|
||||
"tuple(self._compute_domain_context_values())",
|
||||
),
|
||||
)
|
||||
def _compute_domain(self, model_name, mode="read"):
|
||||
"""Inject extra domain for restricting plans and analytical accounts when the
|
||||
user has the group 'Analytic Accounting'.
|
||||
"""
|
||||
res = super()._compute_domain(model_name, mode=mode)
|
||||
user = self.env.user
|
||||
group1 = "base.group_user"
|
||||
group2 = "analytic.group_analytic_accounting"
|
||||
group3 = "analytic_hr_department_restriction.group_analytic_accounting_without_department" # noqa: B950
|
||||
group4 = "account.group_account_invoice"
|
||||
test_condition = not config["test_enable"] or self.env.context.get(
|
||||
"test_analytic_hr_department_restriction"
|
||||
)
|
||||
if (
|
||||
model_name in ("account.analytic.account", "account.analytic.plan")
|
||||
and not self.env.su
|
||||
and user.has_group(group1)
|
||||
and not user.has_group(group4)
|
||||
and test_condition
|
||||
):
|
||||
# We need to get all possible employees of the user in any company (even
|
||||
# if not defined in allowed_company_ids).
|
||||
# Example of use case:
|
||||
# - User: Company A + Company B
|
||||
# - Employee: Company A
|
||||
# - Department: Without company
|
||||
# - Plan: Wihout company + Department
|
||||
# - Purchase Order: Company A + Plan + Department
|
||||
# - If the user accesses the purchase order only with company A, he/she
|
||||
# should be able to see the plan and/or the analytical accounts.
|
||||
# Note: We need to override employee_ids so that when we pass it the
|
||||
# allowed_company_ids context it will return the appropriate value.
|
||||
user.invalidate_recordset(["employee_ids"])
|
||||
user = user.with_context(allowed_company_ids=user.company_ids.ids)
|
||||
if user.has_group(group2):
|
||||
extra_domain = [
|
||||
("department_ids", "child_of", user.employee_ids.department_id.ids)
|
||||
]
|
||||
if user.has_group(group3):
|
||||
extra_domain = expression.OR(
|
||||
[extra_domain, [("department_ids", "=", False)]]
|
||||
)
|
||||
else:
|
||||
extra_domain = [("id", "=", 0)]
|
||||
res = expression.AND([extra_domain] + [res])
|
||||
return res
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
- Your user must have the "Analytic Accounting" permission.
|
||||
- Create an employee linked to your user with a defined department.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
* `Tecnativa <https://www.tecnativa.com>`__:
|
||||
|
||||
* Víctor Martínez
|
||||
* Pedro M. Baeza
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
This module allows you to limit plans and analytical accounts by employee departments.
|
||||
|
||||
Users will only be able to view plans and analytical accounts linked to their employee's department or those with no department defined.
|
||||
|
||||
Users with the "Invoicing / Billing" permission will be able to view all plans and analytical accounts without restrictions.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#. Go to an analytical plan/account and define your employee's department.
|
||||
#. Go to an analytical plan/account and define a different department than your employee's department.
|
||||
#. Go to an analytical plan/account and leave the department empty.
|
||||
#. Users without the "Invoicing / Billing" permission will be able to see only the plans/analytical accounts of the user's employee's department.
|
||||
#. 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 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="group_analytic_accounting_without_department" model="res.groups">
|
||||
<field name="name">Analytic Accounting (without department)</field>
|
||||
<field name="category_id" ref="base.module_category_hidden" />
|
||||
<field
|
||||
name="implied_ids"
|
||||
eval="[(4, ref('analytic.group_analytic_accounting'))]"
|
||||
/>
|
||||
</record>
|
||||
</odoo>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
|
|
@ -0,0 +1,456 @@
|
|||
<!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>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
|
||||
<title>README.rst</title>
|
||||
<style type="text/css">
|
||||
|
||||
/*
|
||||
:Author: David Goodger (goodger@python.org)
|
||||
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
Despite the name, some widely supported CSS2 features are used.
|
||||
|
||||
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
.subscript {
|
||||
vertical-align: sub;
|
||||
font-size: smaller }
|
||||
|
||||
.superscript {
|
||||
vertical-align: super;
|
||||
font-size: smaller }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title, .code .error {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||
clear: left ;
|
||||
float: left ;
|
||||
margin-right: 1em }
|
||||
|
||||
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||
clear: right ;
|
||||
float: right ;
|
||||
margin-left: 1em }
|
||||
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
table.align-center {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.align-left {
|
||||
text-align: left }
|
||||
|
||||
.align-center {
|
||||
clear: both ;
|
||||
text-align: center }
|
||||
|
||||
.align-right {
|
||||
text-align: right }
|
||||
|
||||
/* reset inner alignment in figures */
|
||||
div.align-right {
|
||||
text-align: inherit }
|
||||
|
||||
/* div.align-center * { */
|
||||
/* text-align: left } */
|
||||
|
||||
.align-top {
|
||||
vertical-align: top }
|
||||
|
||||
.align-middle {
|
||||
vertical-align: middle }
|
||||
|
||||
.align-bottom {
|
||||
vertical-align: bottom }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font: inherit }
|
||||
|
||||
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
pre.code .ln { color: gray; } /* line numbers */
|
||||
pre.code, code { background-color: #eeeeee }
|
||||
pre.code .comment, code .comment { color: #5C6576 }
|
||||
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic, pre.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
/* "booktabs" style (no vertical lines) */
|
||||
table.docutils.booktabs {
|
||||
border: 0px;
|
||||
border-top: 2px solid;
|
||||
border-bottom: 2px solid;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.docutils.booktabs * {
|
||||
border: 0px;
|
||||
}
|
||||
table.docutils.booktabs th {
|
||||
border-bottom: thin solid;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document">
|
||||
|
||||
|
||||
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
|
||||
</a>
|
||||
<div class="section" id="analytic-distributions-restriction-per-hr-department">
|
||||
<h1>Analytic distributions restriction per HR department</h1>
|
||||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:df61994dd6701d3ad016addcdd3cbf0ce2dba05a1f1a27a949133ac0d164bb95
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<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/license-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>
|
||||
<p>This module allows you to limit plans and analytical accounts by employee departments.</p>
|
||||
<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>
|
||||
<p>Users with the “Invoicing / Billing” permission will be able to view all plans and analytical accounts without restrictions.</p>
|
||||
<p><strong>Table of contents</strong></p>
|
||||
<div class="contents local topic" id="contents">
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#configuration" id="toc-entry-1">Configuration</a></li>
|
||||
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
|
||||
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
|
||||
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
|
||||
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
|
||||
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
|
||||
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="configuration">
|
||||
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Your user must have the “Analytic Accounting” permission.</li>
|
||||
<li>Create an employee linked to your user with a defined department.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
|
||||
<ol class="arabic simple">
|
||||
<li>Go to an analytical plan/account and define your employee’s department.</li>
|
||||
<li>Go to an analytical plan/account and define a different department than your employee’s department.</li>
|
||||
<li>Go to an analytical plan/account and leave the department empty.</li>
|
||||
<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>
|
||||
<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>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
<h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-analytic/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us to smash it by providing a detailed and welcomed
|
||||
<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>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
<h2><a class="toc-backref" href="#toc-entry-4">Credits</a></h2>
|
||||
<div class="section" id="authors">
|
||||
<h3><a class="toc-backref" href="#toc-entry-5">Authors</a></h3>
|
||||
<ul class="simple">
|
||||
<li>Tecnativa</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="contributors">
|
||||
<h3><a class="toc-backref" href="#toc-entry-6">Contributors</a></h3>
|
||||
<ul class="simple">
|
||||
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
||||
<li>Víctor Martínez</li>
|
||||
<li>Pedro M. Baeza</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
<h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
|
||||
<p>This module is maintained by the OCA.</p>
|
||||
<a class="reference external image-reference" href="https://odoo-community.org">
|
||||
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
|
||||
</a>
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# Copyright 2025 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_analytic_hr_department_restriction
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
# Copyright 2025 Tecnativa - Víctor Martínez
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import Command
|
||||
from odoo.tests import new_test_user
|
||||
from odoo.tests.common import users
|
||||
|
||||
from odoo.addons.base.tests.common import BaseCommon
|
||||
|
||||
|
||||
class TestAnalyticHrDepartmentRestriction(BaseCommon):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.env = cls.env(
|
||||
context=dict(
|
||||
cls.env.context,
|
||||
test_analytic_hr_department_restriction=True,
|
||||
)
|
||||
)
|
||||
cls.department_a = cls.env["hr.department"].create(
|
||||
{
|
||||
"name": "Test department A",
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
cls.department_b = cls.env["hr.department"].create(
|
||||
{
|
||||
"name": "Test department B",
|
||||
"company_id": False,
|
||||
}
|
||||
)
|
||||
cls.basic_user = new_test_user(cls.env, login="test-basic_user")
|
||||
cls.env["hr.employee"].create(
|
||||
{
|
||||
"name": "Test employee Basic",
|
||||
"user_id": cls.basic_user.id,
|
||||
"department_id": cls.department_a.id,
|
||||
}
|
||||
)
|
||||
cls.user = new_test_user(
|
||||
cls.env,
|
||||
login="test-user",
|
||||
groups="base.group_user,analytic.group_analytic_accounting",
|
||||
)
|
||||
cls.env["hr.employee"].create(
|
||||
{
|
||||
"name": "Test employee A",
|
||||
"user_id": cls.user.id,
|
||||
"department_id": cls.department_a.id,
|
||||
}
|
||||
)
|
||||
cls.user_extra = new_test_user(
|
||||
cls.env,
|
||||
login="test-user_extra",
|
||||
groups="base.group_user,analytic_hr_department_restriction.group_analytic_accounting_without_department", # noqa: B950
|
||||
)
|
||||
cls.env["hr.employee"].create(
|
||||
{
|
||||
"name": "Test employee A extra",
|
||||
"user_id": cls.user_extra.id,
|
||||
"department_id": cls.department_a.id,
|
||||
}
|
||||
)
|
||||
cls.manager = new_test_user(
|
||||
cls.env,
|
||||
login="test-manager",
|
||||
groups="account.group_account_invoice,analytic.group_analytic_accounting",
|
||||
)
|
||||
cls.env["hr.employee"].create(
|
||||
{
|
||||
"name": "Test employee B",
|
||||
"user_id": cls.manager.id,
|
||||
"department_id": cls.department_b.id,
|
||||
}
|
||||
)
|
||||
cls.plan_a = cls.env["account.analytic.plan"].create(
|
||||
{
|
||||
"name": "Test plan A",
|
||||
"department_ids": [Command.set(cls.department_a.ids)],
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
cls.account_a = cls.env["account.analytic.account"].create(
|
||||
{
|
||||
"name": "Test account A",
|
||||
"plan_id": cls.plan_a.id,
|
||||
"department_ids": [Command.set(cls.department_a.ids)],
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
cls.plan_b = cls.env["account.analytic.plan"].create(
|
||||
{
|
||||
"name": "Test plan B",
|
||||
"department_ids": [Command.set(cls.department_b.ids)],
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
cls.account_b = cls.env["account.analytic.account"].create(
|
||||
{
|
||||
"name": "Test account B",
|
||||
"plan_id": cls.plan_b.id,
|
||||
"department_ids": [Command.set(cls.department_b.ids)],
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
cls.plan_c = cls.env["account.analytic.plan"].create(
|
||||
{
|
||||
"name": "Test plan C",
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
cls.account_c = cls.env["account.analytic.account"].create(
|
||||
{
|
||||
"name": "Test account C",
|
||||
"plan_id": cls.plan_c.id,
|
||||
"company_id": cls.env.company.id,
|
||||
}
|
||||
)
|
||||
cls.company_extra = cls.env["res.company"].create(
|
||||
{"name": "Test company extra"}
|
||||
)
|
||||
cls.user.write({"company_ids": [Command.link(cls.company_extra.id)]})
|
||||
|
||||
@users("test-basic_user")
|
||||
def test_analytic_data_basic_user(self):
|
||||
accounts = self.env["account.analytic.account"].search([])
|
||||
self.assertNotIn(self.account_a, accounts)
|
||||
self.assertNotIn(self.account_b, accounts)
|
||||
self.assertNotIn(self.account_c, accounts)
|
||||
|
||||
@users("test-user")
|
||||
def test_analytic_data_user(self):
|
||||
plans = self.env["account.analytic.plan"].search([])
|
||||
self.assertIn(self.plan_a, plans)
|
||||
self.assertNotIn(self.plan_b, plans)
|
||||
self.assertNotIn(self.plan_c, plans)
|
||||
accounts = self.env["account.analytic.account"].search([])
|
||||
self.assertIn(self.account_a, accounts)
|
||||
self.assertNotIn(self.account_b, accounts)
|
||||
self.assertNotIn(self.account_c, accounts)
|
||||
|
||||
@users("test-user")
|
||||
def test_analytic_data_user_multi_company(self):
|
||||
# Example of use case:
|
||||
# - User with access to several companies.
|
||||
# - Employee defined in one company
|
||||
# - Department and plan with no company defined
|
||||
# - Purchase order linked to company A (different from the user's employee).
|
||||
# - No access error should be displayed and the user should be able to see
|
||||
# the corresponding plan/analytic account even if the employee's company
|
||||
# is not selected.
|
||||
self.plan_a.company_id = False
|
||||
self.department_a.company_id = False
|
||||
self.plan_b.company_id = False
|
||||
self.plan_c.company_id = False
|
||||
plans = (
|
||||
self.env["account.analytic.plan"]
|
||||
.with_company(self.company_extra.id)
|
||||
.search([])
|
||||
)
|
||||
self.assertIn(self.plan_a, plans)
|
||||
self.assertNotIn(self.plan_b, plans)
|
||||
self.assertNotIn(self.plan_c, plans)
|
||||
self.account_a.company_id = False
|
||||
self.account_b.company_id = False
|
||||
self.account_c.company_id = False
|
||||
accounts = (
|
||||
self.env["account.analytic.account"]
|
||||
.with_company(self.company_extra.id)
|
||||
.search([])
|
||||
)
|
||||
self.assertIn(self.account_a, accounts)
|
||||
self.assertNotIn(self.account_b, accounts)
|
||||
self.assertNotIn(self.account_c, accounts)
|
||||
|
||||
@users("test-user_extra")
|
||||
def test_analytic_data_user_extra(self):
|
||||
plans = self.env["account.analytic.plan"].search([])
|
||||
self.assertIn(self.plan_a, plans)
|
||||
self.assertNotIn(self.plan_b, plans)
|
||||
self.assertIn(self.plan_c, plans)
|
||||
accounts = self.env["account.analytic.account"].search([])
|
||||
self.assertIn(self.account_a, accounts)
|
||||
self.assertNotIn(self.account_b, accounts)
|
||||
self.assertIn(self.account_c, accounts)
|
||||
|
||||
@users("test-manager")
|
||||
def test_analytic_data_manager(self):
|
||||
plans = self.env["account.analytic.plan"].search([])
|
||||
self.assertIn(self.plan_a, plans)
|
||||
self.assertIn(self.plan_b, plans)
|
||||
self.assertIn(self.plan_c, plans)
|
||||
accounts = self.env["account.analytic.account"].search([])
|
||||
self.assertIn(self.account_a, accounts)
|
||||
self.assertIn(self.account_b, accounts)
|
||||
self.assertIn(self.account_c, accounts)
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="view_account_analytic_account_form" model="ir.ui.view">
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="inherit_id" ref="analytic.view_account_analytic_account_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="plan_id" position="before">
|
||||
<field
|
||||
name="department_ids"
|
||||
widget="many2many_tags"
|
||||
groups="account.group_account_invoice"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_account_analytic_account_list" model="ir.ui.view">
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="inherit_id" ref="analytic.view_account_analytic_account_list" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="plan_id" position="after">
|
||||
<field
|
||||
name="department_ids"
|
||||
widget="many2many_tags"
|
||||
groups="account.group_account_invoice"
|
||||
optional="hide"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_account_analytic_account_search" model="ir.ui.view">
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="inherit_id" ref="analytic.view_account_analytic_account_search" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="partner_id" position="after">
|
||||
<field name="department_ids" groups="account.group_account_invoice" />
|
||||
</field>
|
||||
<filter name="associatedpartner" position="after">
|
||||
<filter
|
||||
string="Departments"
|
||||
name="filter_department_ids"
|
||||
domain="[]"
|
||||
groups="account.group_account_invoice"
|
||||
/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="account_analytic_plan_form_view" model="ir.ui.view">
|
||||
<field name="model">account.analytic.plan</field>
|
||||
<field name="inherit_id" ref="analytic.account_analytic_plan_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group//field[@name='company_id']" position="before">
|
||||
<field
|
||||
name="department_ids"
|
||||
widget="many2many_tags"
|
||||
groups="account.group_account_invoice"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="account_analytic_plan_tree_view" model="ir.ui.view">
|
||||
<field name="model">account.analytic.plan</field>
|
||||
<field name="inherit_id" ref="analytic.account_analytic_plan_tree_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="company_id" position="before">
|
||||
<field
|
||||
name="company_id"
|
||||
invisible="1"
|
||||
groups="!base.group_multi_company"
|
||||
/>
|
||||
<field
|
||||
name="department_ids"
|
||||
widget="many2many_tags"
|
||||
groups="account.group_account_invoice"
|
||||
optional="hide"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Architecture
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
U[Users] -->|HTTP| V[Views and QWeb Templates]
|
||||
V --> C[Controllers]
|
||||
V --> W[Wizards – Transient Models]
|
||||
C --> M[Models and ORM]
|
||||
W --> M
|
||||
M --> R[Reports]
|
||||
DX[Data XML] --> M
|
||||
S[Security – ACLs and Groups] -. enforces .-> M
|
||||
|
||||
subgraph Analytic_hr_department_restriction Module - analytic_hr_department_restriction
|
||||
direction LR
|
||||
M:::layer
|
||||
W:::layer
|
||||
C:::layer
|
||||
V:::layer
|
||||
R:::layer
|
||||
S:::layer
|
||||
DX:::layer
|
||||
end
|
||||
|
||||
classDef layer fill:#eef8ff,stroke:#6ea8fe,stroke-width:1px
|
||||
```
|
||||
|
||||
Notes
|
||||
- Views include tree/form/kanban templates and report templates.
|
||||
- Controllers provide website/portal routes when present.
|
||||
- Wizards are UI flows implemented with `models.TransientModel`.
|
||||
- Data XML loads data/demo records; Security defines groups and access.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Configuration
|
||||
|
||||
Refer to Odoo settings for analytic_hr_department_restriction. Configure related models, access rights, and options as needed.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Controllers
|
||||
|
||||
This module does not define custom HTTP controllers.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Dependencies
|
||||
|
||||
This addon depends on:
|
||||
|
||||
- [account](../../odoo-bringout-oca-ocb-account)
|
||||
- [hr](../../odoo-bringout-oca-ocb-hr)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# FAQ
|
||||
|
||||
- Q: Which Odoo version? A: 16.0 (OCA/OCB packaged).
|
||||
- Q: How to enable? A: Start server with --addon analytic_hr_department_restriction or install in UI.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Install
|
||||
|
||||
```bash
|
||||
pip install odoo-bringout-oca-account-analytic-analytic_hr_department_restriction"
|
||||
# or
|
||||
uv pip install odoo-bringout-oca-account-analytic-analytic_hr_department_restriction"
|
||||
```
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# Models
|
||||
|
||||
Detected core models and extensions in analytic_hr_department_restriction.
|
||||
|
||||
```mermaid
|
||||
classDiagram
|
||||
class account_analytic_account
|
||||
class account_analytic_plan
|
||||
class ir_rule
|
||||
```
|
||||
|
||||
Notes
|
||||
- Classes show model technical names; fields omitted for brevity.
|
||||
- Items listed under _inherit are extensions of existing models.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Overview
|
||||
|
||||
Packaged Odoo addon: analytic_hr_department_restriction. Provides features documented in upstream Odoo 16 under this addon.
|
||||
|
||||
- Source: OCA/OCB 16.0, addon analytic_hr_department_restriction
|
||||
- License: LGPL-3
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Reports
|
||||
|
||||
This module does not define custom reports.
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# Security
|
||||
|
||||
Access control and security definitions in analytic_hr_department_restriction.
|
||||
|
||||
## Access Control Lists (ACLs)
|
||||
|
||||
Model access permissions defined in:
|
||||
- **[CHANGELOG.md](../CHANGELOG.md)**
|
||||
- 132 model access rules
|
||||
- **[doc](../doc)**
|
||||
- **[docker](../docker)**
|
||||
- **[input](../input)**
|
||||
- **[nix](../nix)**
|
||||
- **[odoo.conf](../odoo.conf)**
|
||||
- 58 model access rules
|
||||
- **[odoo_packages_bez_l10n.txt](../odoo_packages_bez_l10n.txt)**
|
||||
- 1947 model access rules
|
||||
- **[odoo_packages_bringout.txt](../odoo_packages_bringout.txt)**
|
||||
- 1947 model access rules
|
||||
- **[odoo_packages.txt](../odoo_packages.txt)**
|
||||
- 2085 model access rules
|
||||
- **[output](../output)**
|
||||
- **[packages](../packages)**
|
||||
- **[PACKAGES.md](../PACKAGES.md)**
|
||||
- 298 model access rules
|
||||
- **[README.md](../README.md)**
|
||||
- 338 model access rules
|
||||
- **[scripts](../scripts)**
|
||||
- **[temp](../temp)**
|
||||
- **[TRANSLATION_BS_SUMMARY.md](../TRANSLATION_BS_SUMMARY.md)**
|
||||
- 146 model access rules
|
||||
|
||||
## Record Rules
|
||||
|
||||
Row-level security rules defined in:
|
||||
|
||||
## Security Groups & Configuration
|
||||
|
||||
Security groups and permissions defined in:
|
||||
- **[groups.xml](../analytic_hr_department_restriction/security/groups.xml)**
|
||||
- 1 security groups defined
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
subgraph "Security Layers"
|
||||
A[Users] --> B[Groups]
|
||||
B --> C[Access Control Lists]
|
||||
C --> D[Models]
|
||||
B --> E[Record Rules]
|
||||
E --> F[Individual Records]
|
||||
end
|
||||
```
|
||||
|
||||
Security files overview:
|
||||
- **[groups.xml](../analytic_hr_department_restriction/security/groups.xml)**
|
||||
- Security groups, categories, and XML-based rules
|
||||
|
||||
Notes
|
||||
- Access Control Lists define which groups can access which models
|
||||
- Record Rules provide row-level security (filter records by user/group)
|
||||
- Security groups organize users and define permission sets
|
||||
- All security is enforced at the ORM level by Odoo
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Troubleshooting
|
||||
|
||||
- Ensure Python and Odoo environment matches repo guidance.
|
||||
- Check database connectivity and logs if startup fails.
|
||||
- Validate that dependent addons listed in DEPENDENCIES.md are installed.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Usage
|
||||
|
||||
Start Odoo including this addon (from repo root):
|
||||
|
||||
```bash
|
||||
python3 scripts/nix_odoo_web_server.py --db-name mydb --addon analytic_hr_department_restriction
|
||||
```
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Wizards
|
||||
|
||||
This module does not include UI wizards.
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
[project]
|
||||
name = "odoo-bringout-oca-account-analytic-analytic_hr_department_restriction"
|
||||
version = "16.0.0"
|
||||
description = "Analytic distributions restriction per HR department - Odoo addon"
|
||||
authors = [
|
||||
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
|
||||
]
|
||||
dependencies = [
|
||||
"odoo-bringout-oca-ocb-account>=16.0.0",
|
||||
"odoo-bringout-oca-ocb-hr>=16.0.0",
|
||||
"requests>=2.25.1"
|
||||
]
|
||||
readme = "README.md"
|
||||
requires-python = ">= 3.11"
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Topic :: Office/Business",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
homepage = "https://github.com/bringout/0"
|
||||
repository = "https://github.com/bringout/0"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.metadata]
|
||||
allow-direct-references = true
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["analytic_hr_department_restriction"]
|
||||
|
||||
[tool.rye]
|
||||
managed = true
|
||||
dev-dependencies = [
|
||||
"pytest>=8.4.1",
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue