Skip to content

Commit

Permalink
Merge PR #1881 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Oct 25, 2024
2 parents f56a815 + ba6f61d commit da0d403
Show file tree
Hide file tree
Showing 20 changed files with 935 additions and 0 deletions.
101 changes: 101 additions & 0 deletions partner_category_security/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
=========================
Partner category security
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:afccc3b12250767087509b2039ab4bca6f5d9ef1360cc6ff0c18a1a79ca0ff43
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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_category_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_category_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 adds a specific security group to manage contact tags
(categories).

**Table of contents**

.. contents::
:local:

Usage
=====

1. *Contact Tags > Publisher* permission allows you to modify the tags
assigned to contacts.
2. *Contact Tags > Manager* permission also allows you to manage such
tag (create, modify or remove them).
3. *Contacts > Contact Tags* menu will only be visible if you "Contact
Tags > Manager" permission.
4. *Extra Rights / Contact Creation* and "Internal users" permissions
only allows reading the tags assigned to contacts.

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_category_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
- Pilar Vargas

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_category_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_category_security/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions partner_category_security/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Partner category security",
"version": "17.0.1.0.0",
"category": "Customer Relationship Management",
"website": "https://github.com/OCA/partner-contact",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["contacts"],
"installable": True,
"data": [
"security/security.xml",
"security/ir.model.access.csv",
"views/menu.xml",
],
"maintainers": ["victoralmau"],
}
53 changes: 53 additions & 0 deletions partner_category_security/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_category_security
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-08-25 06:47+0000\n"
"PO-Revision-Date: 2024-01-13 19:35+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\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: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: partner_category_security
#: model:ir.model,name:partner_category_security.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: partner_category_security
#: model:ir.module.category,name:partner_category_security.category_partner_category
#: model:ir.ui.menu,name:partner_category_security.menu_partner_category_custom
msgid "Contact Tags"
msgstr "Etiquetas de contacto"

#. module: partner_category_security
#: model:res.groups,name:partner_category_security.group_partner_category_manager
msgid "Manager"
msgstr "Responsable"

#. module: partner_category_security
#: model:ir.model,name:partner_category_security.model_ir_ui_menu
msgid "Menu"
msgstr ""

#. module: partner_category_security
#: model:res.groups,name:partner_category_security.group_partner_category_user
msgid "Publisher"
msgstr "Editor"

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

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

#~ msgid "Last Modified on"
#~ msgstr "Última Modificación el"
52 changes: 52 additions & 0 deletions partner_category_security/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_category_security
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-04-29 09:36+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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 4.17\n"

#. module: partner_category_security
#: model:ir.model,name:partner_category_security.model_res_partner
msgid "Contact"
msgstr "Contatto"

#. module: partner_category_security
#: model:ir.module.category,name:partner_category_security.category_partner_category
#: model:ir.ui.menu,name:partner_category_security.menu_partner_category_custom
msgid "Contact Tags"
msgstr "Etichette contatto"

#. module: partner_category_security
#: model:res.groups,name:partner_category_security.group_partner_category_manager
msgid "Manager"
msgstr "Responsabile"

#. module: partner_category_security
#: model:ir.model,name:partner_category_security.model_ir_ui_menu
msgid "Menu"
msgstr "Menu"

#. module: partner_category_security
#: model:res.groups,name:partner_category_security.group_partner_category_user
msgid "Publisher"
msgstr "Editore"

#~ msgid "Display Name"
#~ msgstr "Nome visualizzato"

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

#~ msgid "Last Modified on"
#~ msgstr "Ultima modifica il"
40 changes: 40 additions & 0 deletions partner_category_security/i18n/partner_category_security.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * partner_category_security
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.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_category_security
#: model:ir.model,name:partner_category_security.model_res_partner
msgid "Contact"
msgstr ""

#. module: partner_category_security
#: model:ir.module.category,name:partner_category_security.category_partner_category
#: model:ir.ui.menu,name:partner_category_security.menu_partner_category_custom
msgid "Contact Tags"
msgstr ""

#. module: partner_category_security
#: model:res.groups,name:partner_category_security.group_partner_category_manager
msgid "Manager"
msgstr ""

#. module: partner_category_security
#: model:ir.model,name:partner_category_security.model_ir_ui_menu
msgid "Menu"
msgstr ""

#. module: partner_category_security
#: model:res.groups,name:partner_category_security.group_partner_category_user
msgid "Publisher"
msgstr ""
2 changes: 2 additions & 0 deletions partner_category_security/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import ir_ui_menu
from . import res_partner
26 changes: 26 additions & 0 deletions partner_category_security/models/ir_ui_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, models, tools


class IrUiMenu(models.Model):
_inherit = "ir.ui.menu"

@api.model
@tools.ormcache("frozenset(self.env.user.groups_id.ids)", "debug")
def _visible_menu_ids(self, debug=False):
"""It is not possible to set !groups in menu items, we do not return the record
if the user has base.group_system (to avoid the 'duplicate' menu)."""
visible = super()._visible_menu_ids(debug=debug)
user = self.env.user
if (
self.env.su
or user.has_group("base.group_system")
or user.has_group("sales_team.group_sale_manager")
):
menu_partner_category_custom = self.env.ref(
"partner_category_security.menu_partner_category_custom"
)
if menu_partner_category_custom.id in visible:
visible.remove(menu_partner_category_custom.id)
return visible
24 changes: 24 additions & 0 deletions partner_category_security/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2022 Tecnativa - Jairo Llopis
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from lxml import etree

from odoo import api, models


class ResPartner(models.Model):
_inherit = "res.partner"

@api.model
def get_view(self, view_id=None, view_type="form", **options):
"""We define the category_id field read-only if the user does not have
permissions."""
result = super().get_view(view_id, view_type, **options)
category_group = "partner_category_security.group_partner_category_user"
if view_type == "form" and not self.env.user.has_group(category_group):
doc = etree.XML(result["arch"])
nodes = doc.xpath("//field[@name='category_id']")
if nodes:
nodes[0].set("readonly", "1")
nodes[0].set("force_save", "1")
result["arch"] = etree.tostring(doc, encoding="unicode")
return result
3 changes: 3 additions & 0 deletions partner_category_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"
4 changes: 4 additions & 0 deletions partner_category_security/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Tecnativa](https://www.tecnativa.com):
- Víctor Martínez
- Pedro M. Baeza
- Pilar Vargas
2 changes: 2 additions & 0 deletions partner_category_security/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module adds a specific security group to manage contact tags
(categories).
8 changes: 8 additions & 0 deletions partner_category_security/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1. *Contact Tags \> Publisher* permission allows you to modify the tags
assigned to contacts.
2. *Contact Tags \> Manager* permission also allows you to manage such
tag (create, modify or remove them).
3. *Contacts \> Contact Tags* menu will only be visible if you "Contact
Tags \> Manager" permission.
4. *Extra Rights / Contact Creation* and "Internal users" permissions
only allows reading the tags assigned to contacts.
4 changes: 4 additions & 0 deletions partner_category_security/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_res_partner_category_user,res_partner_category_user,base.model_res_partner_category,group_partner_category_user,1,0,0,0
access_res_partner_category_manager,res_partner_category_manager,base.model_res_partner_category,group_partner_category_manager,1,1,1,1
base.access_res_partner_category_group_partner_manager,res_partner_category group_partner_manager,base.model_res_partner_category,base.group_partner_manager,1,0,0,0
20 changes: 20 additions & 0 deletions partner_category_security/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" ?>
<odoo>
<record id="category_partner_category" model="ir.module.category">
<field name="name">Contact Tags</field>
</record>
<record id="group_partner_category_user" model="res.groups">
<field name="name">Publisher</field>
<field name="category_id" ref="category_partner_category" />
<field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
</record>
<record id="group_partner_category_manager" model="res.groups">
<field name="name">Manager</field>
<field name="implied_ids" eval="[(4, ref('group_partner_category_user'))]" />
<field name="category_id" ref="category_partner_category" />
<field
name="users"
eval="[(4, ref('base.user_root')), (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 da0d403

Please sign in to comment.