Skip to content

Commit

Permalink
Merge pull request #1232 from OCA/17.0
Browse files Browse the repository at this point in the history
Syncing from upstream OCA/product-attribute (17.0)
  • Loading branch information
bt-admin authored Jan 26, 2025
2 parents 6491a33 + 74dd0fa commit ce789a6
Show file tree
Hide file tree
Showing 21 changed files with 876 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ addon | version | maintainers | summary
[product_pricelist_supplierinfo](product_pricelist_supplierinfo/) | 17.0.2.0.0 | [![luisg123v](https://github.com/luisg123v.png?size=30px)](https://github.com/luisg123v) | Allows to create priceslists based on supplier info
[product_print_category](product_print_category/) | 17.0.1.0.1 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Define print categories for products and automate products print, when data has changed
[product_product_template_link](product_product_template_link/) | 17.0.1.0.0 | | Adds a button in product to view the template
[product_readonly_security](product_readonly_security/) | 17.0.1.0.0 | [![victoralmau](https://github.com/victoralmau.png?size=30px)](https://github.com/victoralmau) | Product Readonly Security
[product_secondary_unit](product_secondary_unit/) | 17.0.1.0.0 | [![sergio-teruel](https://github.com/sergio-teruel.png?size=30px)](https://github.com/sergio-teruel) | Set a secondary unit per product
[product_sequence](product_sequence/) | 17.0.1.0.0 | | Product Sequence
[product_set](product_set/) | 17.0.1.0.1 | | Product set
Expand Down
96 changes: 96 additions & 0 deletions product_readonly_security/README.rst
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:1fbf72621be7eb7439cffc9e126a94db5f7075bba4bf50a6a696fe597d474ba9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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.
1 change: 1 addition & 0 deletions product_readonly_security/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions product_readonly_security/__manifest__.py
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"],
}
61 changes: 61 additions & 0 deletions product_readonly_security/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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,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_template
msgid "Product"
msgstr "Producto"

#. module: product_readonly_security
#: model:ir.model,name:product_readonly_security.model_product_product
msgid "Product Variant"
msgstr ""

#. 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
#. odoo-python
#: 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."

#~ msgid "Display Name"
#~ msgstr "Nombre mostrado"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Última Modificación el"

#~ msgid "Product Template"
#~ msgstr "Plantilla de producto"
48 changes: 48 additions & 0 deletions product_readonly_security/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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"
"PO-Revision-Date: 2025-01-25 15:06+0000\n"
"Last-Translator: mymage <[email protected]>\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.6.2\n"

#. module: product_readonly_security
#: model:ir.model,name:product_readonly_security.model_product_readonly_security_mixin
msgid "Mixin to use Product Readonly Security"
msgstr "Mixin per utilizzare la ricurezza solo lettura prodotto"

#. module: product_readonly_security
#: model:ir.model,name:product_readonly_security.model_product_template
msgid "Product"
msgstr "Prodotto"

#. module: product_readonly_security
#: model:ir.model,name:product_readonly_security.model_product_product
msgid "Product Variant"
msgstr "Variante prodotto"

#. module: product_readonly_security
#: model:res.groups,name:product_readonly_security.group_product_edition
msgid "Product edition"
msgstr "Edizione prodotto"

#. module: product_readonly_security
#. odoo-python
#: 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 ""
"Spiacenti, non è consentito creare/modificare prodotti. Contattare il tuo "
"amministratore per ulteriori informazioni."
43 changes: 43 additions & 0 deletions product_readonly_security/i18n/product_readonly_security.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_readonly_security
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.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,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_template
msgid "Product"
msgstr ""

#. module: product_readonly_security
#: model:ir.model,name:product_readonly_security.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_readonly_security
#: model:res.groups,name:product_readonly_security.group_product_edition
msgid "Product edition"
msgstr ""

#. module: product_readonly_security
#. odoo-python
#: 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 ""
5 changes: 5 additions & 0 deletions product_readonly_security/models/__init__.py
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
9 changes: 9 additions & 0 deletions product_readonly_security/models/product_product.py
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"]
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
)
9 changes: 9 additions & 0 deletions product_readonly_security/models/product_template.py
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"]
3 changes: 3 additions & 0 deletions product_readonly_security/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions product_readonly_security/readme/CONTRIBUTORS.md
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
2 changes: 2 additions & 0 deletions product_readonly_security/readme/DESCRIPTION.md
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.
4 changes: 4 additions & 0 deletions product_readonly_security/readme/USAGE.md
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="group_product_edition" model="res.groups">
<field name="name">Product edition</field>
<field name="category_id" ref="base.module_category_usability" />
<field name="users" eval="[(4, ref('base.user_admin'))]" />
</record>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ce789a6

Please sign in to comment.