-
-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
19 changed files
with
917 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,96 @@ | ||
========================= | ||
Product Readonly Security | ||
========================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:08b9a36e9baa72afe08bf9593d451e14c246ce87d13f887fd84b8e23932d2c4f | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/licence-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%2Fproduct--attribute-lightgray.png?logo=github | ||
:target: https://github.com/OCA/product-attribute/tree/17.0/product_readonly_security | ||
:alt: OCA/product-attribute | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/product-attribute-17-0/product-attribute-17-0-product_readonly_security | ||
: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/product-attribute&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module creates a specific permission to allow modification of | ||
products and variants. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
1. Create or edit a user and uncheck the 'Product edition' permission. | ||
2. Login with that user. | ||
3. Go to any product. | ||
4. None can be created, modified or deleted. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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/product-attribute/issues/new?body=module:%20product_readonly_security%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 | ||
------- | ||
|
||
* 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/product-attribute <https://github.com/OCA/product-attribute/tree/17.0/product_readonly_security>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains 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 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,14 @@ | ||
# Copyright 2024 Tecnativa - Víctor Martínez | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
{ | ||
"name": "Product Readonly Security", | ||
"author": "Tecnativa, Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/product-attribute", | ||
"version": "17.0.1.0.0", | ||
"depends": ["product"], | ||
"license": "AGPL-3", | ||
"category": "Product", | ||
"data": ["security/product_readonly_security.xml"], | ||
"installable": True, | ||
"maintainers": ["victoralmau"], | ||
} |
This file contains 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,69 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * product_readonly_security | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 13.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-08-19 07:21+0000\n" | ||
"PO-Revision-Date: 2024-08-19 09:22+0200\n" | ||
"Last-Translator: \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: \n" | ||
"X-Generator: Poedit 3.0.1\n" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product__display_name | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin__display_name | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template__display_name | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product__id | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin__id | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product____last_update | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin____last_update | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última Modificación el" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_readonly_security_mixin | ||
msgid "Mixin to use Product Readonly Security" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_product | ||
msgid "Product" | ||
msgstr "Producto" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_template | ||
msgid "Product Template" | ||
msgstr "Plantilla de producto" | ||
|
||
#. module: product_readonly_security | ||
#: model:res.groups,name:product_readonly_security.group_product_edition | ||
msgid "Product edition" | ||
msgstr "Edición de productos" | ||
|
||
#. module: product_readonly_security | ||
#: code:addons/product_readonly_security/models/product_readonly_security_mixin.py:0 | ||
#, python-format | ||
msgid "" | ||
"Sorry, you are not allowed to create/edit products. Please contact your " | ||
"administrator for further information." | ||
msgstr "" | ||
"Lo sentimos, no tiene permiso para crear/editar productos. Para más " | ||
"información, póngase en contacto con su administrador." |
This file contains 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,64 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * product_readonly_security | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: Automatically generated\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" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product__display_name | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin__display_name | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product__id | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin__id | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product____last_update | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin____last_update | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_readonly_security_mixin | ||
msgid "Mixin to use Product Readonly Security" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_product | ||
msgid "Product" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_template | ||
msgid "Product Template" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:res.groups,name:product_readonly_security.group_product_edition | ||
msgid "Product edition" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: code:addons/product_readonly_security/models/product_readonly_security_mixin.py:0 | ||
#, python-format | ||
msgid "" | ||
"Sorry, you are not allowed to create/edit products. Please contact your " | ||
"administrator for further information." | ||
msgstr "" |
63 changes: 63 additions & 0 deletions
63
product_readonly_security/i18n/product_readonly_security.pot
This file contains 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,63 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * product_readonly_security | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.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: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product__display_name | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin__display_name | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product__id | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin__id | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_product____last_update | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_readonly_security_mixin____last_update | ||
#: model:ir.model.fields,field_description:product_readonly_security.field_product_template____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_readonly_security_mixin | ||
msgid "Mixin to use Product Readonly Security" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_product | ||
msgid "Product" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:ir.model,name:product_readonly_security.model_product_template | ||
msgid "Product Template" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: model:res.groups,name:product_readonly_security.group_product_edition | ||
msgid "Product edition" | ||
msgstr "" | ||
|
||
#. module: product_readonly_security | ||
#: code:addons/product_readonly_security/models/product_readonly_security_mixin.py:0 | ||
#, python-format | ||
msgid "" | ||
"Sorry, you are not allowed to create/edit products. Please contact your " | ||
"administrator for further information." | ||
msgstr "" |
This file contains 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,5 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import product_readonly_security_mixin | ||
from . import product_product | ||
from . import product_template |
This file contains 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 @@ | ||
# Copyright 2024 Tecnativa - Víctor Martínez | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_name = "product.product" | ||
_inherit = ["product.product", "product.readonly.security.mixin"] |
40 changes: 40 additions & 0 deletions
40
product_readonly_security/models/product_readonly_security_mixin.py
This file contains 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,40 @@ | ||
# Copyright 2024 Tecnativa - Víctor Martínez | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from odoo import _, api, models | ||
from odoo.exceptions import AccessError | ||
from odoo.tools import config | ||
|
||
|
||
class ProductReadonlySecurityMixin(models.AbstractModel): | ||
_name = "product.readonly.security.mixin" | ||
_description = "Mixin to use Product Readonly Security" | ||
|
||
@api.model | ||
def check_access_rights(self, operation, raise_exception=True): | ||
# Override security returning False/AccessError if not belonging to | ||
# the new security group. This makest that the create, edit and delete | ||
# buttons are not displayed. | ||
user = self.env.user | ||
group = "product_readonly_security.group_product_edition" | ||
test_condition = not config["test_enable"] or ( | ||
config["test_enable"] | ||
and self.env.context.get("test_product_readonly_security") | ||
) | ||
if ( | ||
test_condition | ||
and operation != "read" | ||
and not self.env.su | ||
and not user.has_group(group) | ||
): | ||
if raise_exception: | ||
raise AccessError( | ||
_( | ||
"Sorry, you are not allowed to create/edit products. Please " | ||
"contact your administrator for further information." | ||
) | ||
) | ||
return False | ||
return super().check_access_rights( | ||
operation=operation, raise_exception=raise_exception | ||
) |
This file contains 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 @@ | ||
# Copyright 2024 Tecnativa - Víctor Martínez | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_name = "product.template" | ||
_inherit = ["product.template", "product.readonly.security.mixin"] |
This file contains 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,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains 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,3 @@ | ||
- [Tecnativa](https://www.tecnativa.com): | ||
- Víctor Martínez | ||
- Pedro M. Baeza |
This file contains 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 @@ | ||
This module creates a specific permission to allow modification of | ||
products and variants. |
This file contains 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,4 @@ | ||
1. Create or edit a user and uncheck the 'Product edition' permission. | ||
2. Login with that user. | ||
3. Go to any product. | ||
4. None can be created, modified or deleted. |
Oops, something went wrong.