Skip to content
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

[17.0][MIG] partner_readonly_security #1957

Open
wants to merge 5 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions partner_readonly_security/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
=========================
Partner Readonly Security
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:3d6246358978797b076968ddd67431d45985450a8ca6132a0cea259afbd8e162
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/17.0/partner_readonly_security
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-17-0/partner-contact-17-0-partner_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/partner-contact&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module creates a specific permission to allow modification of
partners.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

Example use case: sales manager doesn't edit partners.

Usage
=====

1. Create or edit a user and uncheck the 'Partner edition' permission.
2. Go to any contact.
3. None can be created, modified or deleted.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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/partner-contact/issues/new?body=module:%20partner_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/partner-contact <https://github.com/OCA/partner-contact/tree/17.0/partner_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 partner_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 partner_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": "Partner Readonly Security",
"author": "Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/partner-contact",
"version": "17.0.1.0.0",
"depends": ["base"],
"license": "AGPL-3",
"category": "Customer Relationship Management",
"data": ["security/partner_readonly_security_security.xml"],
"installable": True,
"maintainers": ["victoralmau"],
}
38 changes: 38 additions & 0 deletions partner_readonly_security/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_readonly_security
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-05-30 12:08+0000\n"
"PO-Revision-Date: 2024-05-30 14:09+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: partner_readonly_security
#: model:ir.model,name:partner_readonly_security.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: partner_readonly_security
#: model:res.groups,name:partner_readonly_security.group_partner_edition
msgid "Partner edition"
msgstr "Edición de contactos"

#. module: partner_readonly_security
#: code:addons/partner_readonly_security/models/res_partner.py:0
#, python-format
msgid ""
"Sorry, you are not allowed to create/edit partners. Please contact your "
"administrator for further information."
msgstr ""
"Lo sentimos, no tiene permiso para crear/editar contactos. Para más "
"información, póngase en contacto con su administrador."
32 changes: 32 additions & 0 deletions partner_readonly_security/i18n/partner_readonly_security.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_readonly_security
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.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: partner_readonly_security
#: model:ir.model,name:partner_readonly_security.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_readonly_security
#: model:res.groups,name:partner_readonly_security.group_partner_edition
msgid "Partner edition"
msgstr ""

#. module: partner_readonly_security
#: code:addons/partner_readonly_security/models/res_partner.py:0
#, python-format
msgid ""
"Sorry, you are not allowed to create/edit partners. Please contact your "
"administrator for further information."
msgstr ""
3 changes: 3 additions & 0 deletions partner_readonly_security/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import res_partner
38 changes: 38 additions & 0 deletions partner_readonly_security/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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 ResPartner(models.Model):
_inherit = "res.partner"

@api.model
def check_access_rights(self, operation, raise_exception=True):
"""Simulate that you do not have ACLs so that the create, edit and delete
buttons are not displayed."""
user = self.env.user
group = "partner_readonly_security.group_partner_edition"
test_condition = not config["test_enable"] or (
config["test_enable"]
and self.env.context.get("test_partner_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 partners. Please "
"contact your administrator for further information."
)
)
return False
return super().check_access_rights(
operation=operation, raise_exception=raise_exception
)
3 changes: 3 additions & 0 deletions partner_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"
1 change: 1 addition & 0 deletions partner_readonly_security/readme/CONTEXT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Example use case: sales manager doesn't edit partners.
3 changes: 3 additions & 0 deletions partner_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 partner_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
partners.
3 changes: 3 additions & 0 deletions partner_readonly_security/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1. Create or edit a user and uncheck the 'Partner edition' permission.
2. Go to any contact.
3. 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_partner_edition" model="res.groups">
<field name="name">Partner 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
Loading