diff --git a/project_create_restriction/README.rst b/project_create_restriction/README.rst new file mode 100644 index 0000000..4af6340 --- /dev/null +++ b/project_create_restriction/README.rst @@ -0,0 +1,74 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +========================== +Project Create Restriction +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:dde70dd2e06c3607caf308408c696f6be6c56da4d0846bf3da2b080b3d695a2e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-solvosci%2Fslv--project-lightgray.png?logo=github + :target: https://github.com/solvosci/slv-project/tree/17.0/project_create_restriction + :alt: solvosci/slv-project + +|badge1| |badge2| |badge3| + +Adds an extra access control layer on projects and tasks. + +A dedicated security group is introduced by this module and can be found +under the "Extra Rights" category. Only users belonging to this group +are allowed to create or delete projects and tasks. + +Other users can still access and work with existing records according to +standard Odoo permissions. + +This module is inspired by existing OCA security addons such as +product_readonly_security. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Solvos + +Contributors +------------ + +- Carlos García + +Maintainers +----------- + +This module is part of the `solvosci/slv-project `_ project on GitHub. + +You are welcome to contribute. diff --git a/project_create_restriction/__init__.py b/project_create_restriction/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/project_create_restriction/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_create_restriction/__manifest__.py b/project_create_restriction/__manifest__.py new file mode 100644 index 0000000..b1f304b --- /dev/null +++ b/project_create_restriction/__manifest__.py @@ -0,0 +1,20 @@ +# © 2026 Solvos Consultoría Informática () +# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html +{ + "name": "Project Create Restriction", + "summary": """ + Restrict project and task creation based on user groups + """, + "author": "Solvos", + "license": "LGPL-3", + "version": "17.0.1.0.0", + "category": "Project", + "website": "https://github.com/solvosci/slv-project", + "depends": [ + "project", + ], + "data": [ + "security/security.xml", + ], + "installable": True, +} diff --git a/project_create_restriction/i18n/es.po b/project_create_restriction/i18n/es.po new file mode 100644 index 0000000..2ab74cc --- /dev/null +++ b/project_create_restriction/i18n/es.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_create_restriction +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-01-19 12:56+0000\n" +"PO-Revision-Date: 2026-01-19 12:56+0000\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: project_create_restriction +#: model:ir.model,name:project_create_restriction.model_project_project +msgid "Project" +msgstr "Proyecto" + +#. module: project_create_restriction +#: model:res.groups,name:project_create_restriction.group_project_create_projects_tasks +msgid "Projects: can create projects and/or tasks" +msgstr "Proyectos: puede crear proyectos y/o tareas" + +#. module: project_create_restriction +#: model:ir.model,name:project_create_restriction.model_project_task +msgid "Task" +msgstr "Tarea" + +#. module: project_create_restriction +#. odoo-python +#: code:addons/project_create_restriction/models/project_task.py:0 +#, python-format +msgid "" +"You are not allowed to create or delete tasks." +msgstr "No estás habilitado para crear o borrar tareas" + +#. module: project_create_restriction +#. odoo-python +#: code:addons/project_create_restriction/models/project_project.py:0 +#, python-format +msgid "You are not allowed to create, edit or delete projects. " +msgstr "No estás habilitado para crear, editar o eliminar proyectos" diff --git a/project_create_restriction/i18n/project_create_restriction.pot b/project_create_restriction/i18n/project_create_restriction.pot new file mode 100644 index 0000000..e7c1424 --- /dev/null +++ b/project_create_restriction/i18n/project_create_restriction.pot @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_create_restriction +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-01-19 12:55+0000\n" +"PO-Revision-Date: 2026-01-19 12:55+0000\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: project_create_restriction +#: model:ir.model,name:project_create_restriction.model_project_project +msgid "Project" +msgstr "" + +#. module: project_create_restriction +#: model:res.groups,name:project_create_restriction.group_project_create_projects_tasks +msgid "Projects: can create projects and/or tasks" +msgstr "" + +#. module: project_create_restriction +#: model:ir.model,name:project_create_restriction.model_project_task +msgid "Task" +msgstr "" + +#. module: project_create_restriction +#. odoo-python +#: code:addons/project_create_restriction/models/project_task.py:0 +#, python-format +msgid "" +"You are not allowed to create or delete tasks. Please contact your " +"administrator for further information." +msgstr "" + +#. module: project_create_restriction +#. odoo-python +#: code:addons/project_create_restriction/models/project_project.py:0 +#, python-format +msgid "You are not allowed to create, edit or delete projects. " +msgstr "" diff --git a/project_create_restriction/models/__init__.py b/project_create_restriction/models/__init__.py new file mode 100644 index 0000000..2128188 --- /dev/null +++ b/project_create_restriction/models/__init__.py @@ -0,0 +1,2 @@ +from . import project_project +from . import project_task diff --git a/project_create_restriction/models/project_project.py b/project_create_restriction/models/project_project.py new file mode 100644 index 0000000..aaaaf48 --- /dev/null +++ b/project_create_restriction/models/project_project.py @@ -0,0 +1,31 @@ +# © 2026 Solvos Consultoría Informática () +# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html + +from odoo import api, models, _ +from odoo.exceptions import AccessError + + +class Project(models.Model): + _inherit = "project.project" + + @api.model + def check_access_rights(self, operation, raise_exception=True): + user = self.env.user + group = "project_create_restriction.group_project_create_projects_tasks" + admin_user = self.env.ref("base.user_root") + + if ( + operation != "read" + and user != admin_user + and not user.has_group(group) + ): + if raise_exception: + raise AccessError( + _( + "You are not allowed to create, edit or delete projects. " + ) + ) + return False + + return super().check_access_rights(operation, raise_exception) + diff --git a/project_create_restriction/models/project_task.py b/project_create_restriction/models/project_task.py new file mode 100644 index 0000000..82402de --- /dev/null +++ b/project_create_restriction/models/project_task.py @@ -0,0 +1,30 @@ +# © 2026 Solvos Consultoría Informática () +# License LGPL-3 - See http://www.gnu.org/licenses/lgpl-3.0.html + +from odoo import api, models, _ +from odoo.exceptions import AccessError + + +class ProjectTask(models.Model): + _inherit = "project.task" + + @api.model + def check_access_rights(self, operation, raise_exception=True): + user = self.env.user + group = "project_create_restriction.group_project_create_projects_tasks" + admin_user = self.env.ref("base.user_root") + + if ( + operation in ("create", "unlink") + and user != admin_user + and not user.has_group(group) + ): + if raise_exception: + raise AccessError( + _( + "You are not allowed to create or delete tasks. " + ) + ) + return False + + return super().check_access_rights(operation, raise_exception) diff --git a/project_create_restriction/readme/CONTRIBUTORS.md b/project_create_restriction/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..bf8b659 --- /dev/null +++ b/project_create_restriction/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Carlos García \<\> diff --git a/project_create_restriction/readme/DESCRIPTION.md b/project_create_restriction/readme/DESCRIPTION.md new file mode 100644 index 0000000..632c2df --- /dev/null +++ b/project_create_restriction/readme/DESCRIPTION.md @@ -0,0 +1,11 @@ +Adds an extra access control layer on projects and tasks. + +A dedicated security group is introduced by this module and can be found +under the "Extra Rights" category. Only users belonging to this group are +allowed to create or delete projects and tasks. + +Other users can still access and work with existing records according to +standard Odoo permissions. + +This module is inspired by existing OCA security addons such as +product_readonly_security. diff --git a/project_create_restriction/security/security.xml b/project_create_restriction/security/security.xml new file mode 100644 index 0000000..bdef6b6 --- /dev/null +++ b/project_create_restriction/security/security.xml @@ -0,0 +1,9 @@ + + + + Projects: can create projects and/or tasks + + + + + diff --git a/project_create_restriction/static/description/icon.png b/project_create_restriction/static/description/icon.png new file mode 100644 index 0000000..daa2a02 Binary files /dev/null and b/project_create_restriction/static/description/icon.png differ diff --git a/project_create_restriction/static/description/index.html b/project_create_restriction/static/description/index.html new file mode 100644 index 0000000..9a668f9 --- /dev/null +++ b/project_create_restriction/static/description/index.html @@ -0,0 +1,429 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Project Create Restriction

+ +

Beta License: LGPL-3 solvosci/slv-project

+

Adds an extra access control layer on projects and tasks.

+

A dedicated security group is introduced by this module and can be found +under the “Extra Rights” category. Only users belonging to this group +are allowed to create or delete projects and tasks.

+

Other users can still access and work with existing records according to +standard Odoo permissions.

+

This module is inspired by existing OCA security addons such as +product_readonly_security.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Solvos
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the solvosci/slv-project project on GitHub.

+

You are welcome to contribute.

+
+
+
+
+ +