-
Notifications
You must be signed in to change notification settings - Fork 0
[17.0][ADD] project_create_restriction #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cgarcia-solvos
wants to merge
1
commit into
17.0
Choose a base branch
from
17.0-add-project_create_restriction
base: 17.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <https://github.com/solvosci/slv-project/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/solvosci/slv-project/issues/new?body=module:%20project_create_restriction%0Aversion:%2017.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 | ||
| ------- | ||
|
|
||
| * Solvos | ||
|
|
||
| Contributors | ||
| ------------ | ||
|
|
||
| - Carlos García <carlos.garcia@solvos.es> | ||
|
|
||
| Maintainers | ||
| ----------- | ||
|
|
||
| This module is part of the `solvosci/slv-project <https://github.com/solvosci/slv-project/tree/17.0/project_create_restriction>`_ project on GitHub. | ||
|
|
||
| You are welcome to contribute. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # © 2026 Solvos Consultoría Informática (<http://www.solvos.es>) | ||
| # 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, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" |
47 changes: 47 additions & 0 deletions
47
project_create_restriction/i18n/project_create_restriction.pot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import project_project | ||
| from . import project_task |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # © 2026 Solvos Consultoría Informática (<http://www.solvos.es>) | ||
| # 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) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # © 2026 Solvos Consultoría Informática (<http://www.solvos.es>) | ||
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Carlos García \<<carlos.garcia@solvos.es>\> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <odoo> | ||
|
|
||
| <record id="group_project_create_projects_tasks" model="res.groups"> | ||
| <field name="name">Projects: can create projects and/or tasks</field> | ||
| <field name="category_id" ref="base.module_category_usability" /> | ||
| <field name="implied_ids" eval="[(4, ref('project.group_project_manager'))]"/> | ||
| </record> | ||
|
|
||
| </odoo> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.