diff --git a/crm_security_group/README.rst b/crm_security_group/README.rst new file mode 100644 index 00000000000..c0fe07b9bb3 --- /dev/null +++ b/crm_security_group/README.rst @@ -0,0 +1,91 @@ +======================== +CRM Only Security Groups +======================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9bd268e2f74a9fcfab1fdb5e2a80aa9a0f11c96f7a6a2b770c7b8dc0e22200a2 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fcrm-lightgray.png?logo=github + :target: https://github.com/OCA/crm/tree/16.0/crm_security_group + :alt: OCA/crm +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/crm-16-0/crm-16-0-crm_security_group + :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/crm&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds new security options to CRM by creating 3 groups (Own Documents Only, All Documents and Administrator) to separate Sales and CRM apps permissions + +**Table of contents** + +.. contents:: + :local: + +Known issues / Roadmap +====================== + +- Remove sale_crm dependency (now is not possible), maybe split this part in other addon + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + +* `Tecnativa `__: + + * Víctor Martínez + +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 `__: + +|maintainer-victoralmau| + +This module is part of the `OCA/crm `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/crm_security_group/__init__.py b/crm_security_group/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/crm_security_group/__manifest__.py b/crm_security_group/__manifest__.py new file mode 100644 index 00000000000..66b3777b7ba --- /dev/null +++ b/crm_security_group/__manifest__.py @@ -0,0 +1,23 @@ +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "CRM Only Security Groups", + "summary": "Add new group in Sales to show only CRM", + "version": "16.0.1.0.0", + "category": "Customer Relationship Management", + "website": "https://github.com/OCA/crm", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": ["crm", "sale_crm"], + # sale_crm dependency is necessary to add groups in some view + "maintainers": ["victoralmau"], + "data": [ + "security/security.xml", + "security/ir.model.access.csv", + "views/crm_lead_views.xml", + "views/crm_team_views.xml", + "views/menu_items.xml", + ], +} diff --git a/crm_security_group/i18n/crm_security_group.pot b/crm_security_group/i18n/crm_security_group.pot new file mode 100644 index 00000000000..017754df9ef --- /dev/null +++ b/crm_security_group/i18n/crm_security_group.pot @@ -0,0 +1,34 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_security_group +# +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: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_manager +msgid "Administrator" +msgstr "" + +#. module: crm_security_group +#: model:ir.module.category,name:crm_security_group.module_category_crm_crm +msgid "CRM" +msgstr "" + +#. module: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_all_leads +msgid "User: All Documents" +msgstr "" + +#. module: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_own_leads +msgid "User: Own Documents Only" +msgstr "" diff --git a/crm_security_group/i18n/es.po b/crm_security_group/i18n/es.po new file mode 100644 index 00000000000..a3de7328184 --- /dev/null +++ b/crm_security_group/i18n/es.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_security_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-08-17 14:11+0000\n" +"Last-Translator: Víctor Martínez \n" +"Language-Team: none\n" +"Language: es\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: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_manager +msgid "Administrator" +msgstr "Administrador" + +#. module: crm_security_group +#: model:ir.module.category,name:crm_security_group.module_category_crm_crm +msgid "CRM" +msgstr "CRM" + +#. module: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_all_leads +msgid "User: All Documents" +msgstr "Usuario: Todos los documentos" + +#. module: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_own_leads +msgid "User: Own Documents Only" +msgstr "Usuario: Mostrar solo documentos propios" diff --git a/crm_security_group/i18n/it.po b/crm_security_group/i18n/it.po new file mode 100644 index 00000000000..98163d34a10 --- /dev/null +++ b/crm_security_group/i18n/it.po @@ -0,0 +1,37 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * crm_security_group +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-06-13 16:12+0000\n" +"Last-Translator: mymage \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: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_manager +msgid "Administrator" +msgstr "Amministratore" + +#. module: crm_security_group +#: model:ir.module.category,name:crm_security_group.module_category_crm_crm +msgid "CRM" +msgstr "CRM" + +#. module: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_all_leads +msgid "User: All Documents" +msgstr "Utente: tutti i documenti" + +#. module: crm_security_group +#: model:res.groups,name:crm_security_group.group_crm_own_leads +msgid "User: Own Documents Only" +msgstr "Utente: solo i propri documenti" diff --git a/crm_security_group/readme/CONTRIBUTORS.rst b/crm_security_group/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..ae3b3ea56a3 --- /dev/null +++ b/crm_security_group/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Tecnativa `__: + + * Víctor Martínez diff --git a/crm_security_group/readme/DESCRIPTION.rst b/crm_security_group/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..d5dca4251d6 --- /dev/null +++ b/crm_security_group/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +This module adds new security options to CRM by creating 3 groups (Own Documents Only, All Documents and Administrator) to separate Sales and CRM apps permissions diff --git a/crm_security_group/readme/ROADMAP.rst b/crm_security_group/readme/ROADMAP.rst new file mode 100644 index 00000000000..8a223582a92 --- /dev/null +++ b/crm_security_group/readme/ROADMAP.rst @@ -0,0 +1 @@ +- Remove sale_crm dependency (now is not possible), maybe split this part in other addon diff --git a/crm_security_group/security/ir.model.access.csv b/crm_security_group/security/ir.model.access.csv new file mode 100644 index 00000000000..f37b8cf6358 --- /dev/null +++ b/crm_security_group/security/ir.model.access.csv @@ -0,0 +1,10 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_crm_lead_user,crm.lead.user,crm.model_crm_lead,crm_security_group.group_crm_own_leads,1,1,1,0 +access_crm_team_user,crm.team.user,sales_team.model_crm_team,crm_security_group.group_crm_own_leads,1,0,0,0 +access_crm_team_manager,crm.team.manager,sales_team.model_crm_team,crm_security_group.group_crm_own_leads,1,1,1,1 +access_crm_stage_manager,crm.stage.manager,crm.model_crm_stage,crm_security_group.group_crm_manager,1,1,1,1 +access_crm_tag_own_leads,sale_team.crm.tag.own.leads,sales_team.model_crm_tag,crm_security_group.group_crm_own_leads,1,1,1,0 +access_crm_tag_manager,sale_team.crm.tag.manager,sales_team.model_crm_tag,crm_security_group.group_crm_manager,1,1,1,1 +access_crm_lead_scoring_frequency_user,crm.lead.scoring.frequency.user,crm.model_crm_lead_scoring_frequency,crm_security_group.group_crm_own_leads,1,0,0,0 +access_crm_lead_scoring_frequency_field_user,crm.lead.scoring.frequency.field.user,crm.model_crm_lead_scoring_frequency_field,crm_security_group.group_crm_own_leads,1,0,0,0 +access_crm_lead_lost_user,crm.lead.user,crm.model_crm_lead_lost,crm_security_group.group_crm_own_leads,1,1,1,0 diff --git a/crm_security_group/security/security.xml b/crm_security_group/security/security.xml new file mode 100644 index 00000000000..f8488c6b28c --- /dev/null +++ b/crm_security_group/security/security.xml @@ -0,0 +1,54 @@ + + + + CRM + + + + User: Own Documents Only + + + + + User: All Documents + + + + + Administrator + + + + + + + Personal Leads + + ['|',('user_id','=',user.id),('user_id','=',False)] + + + + All Leads + + [(1,'=',1)] + + + + diff --git a/crm_security_group/static/description/icon.png b/crm_security_group/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/crm_security_group/static/description/icon.png differ diff --git a/crm_security_group/static/description/index.html b/crm_security_group/static/description/index.html new file mode 100644 index 00000000000..cc11a470b09 --- /dev/null +++ b/crm_security_group/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +CRM Only Security Groups + + + +
+

CRM Only Security Groups

+ + +

Beta License: AGPL-3 OCA/crm Translate me on Weblate Try me on Runboat

+

This module adds new security options to CRM by creating 3 groups (Own Documents Only, All Documents and Administrator) to separate Sales and CRM apps permissions

+

Table of contents

+ +
+

Known issues / Roadmap

+
    +
  • Remove sale_crm dependency (now is not possible), maybe split this part in other addon
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

victoralmau

+

This module is part of the OCA/crm project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/crm_security_group/tests/__init__.py b/crm_security_group/tests/__init__.py new file mode 100644 index 00000000000..bcb33e9f7e1 --- /dev/null +++ b/crm_security_group/tests/__init__.py @@ -0,0 +1,2 @@ +# License LGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html +from . import test_crm_security diff --git a/crm_security_group/tests/test_crm_security.py b/crm_security_group/tests/test_crm_security.py new file mode 100644 index 00000000000..d8c9b018373 --- /dev/null +++ b/crm_security_group/tests/test_crm_security.py @@ -0,0 +1,95 @@ +# Copyright 2021-2023 Tecnativa - Víctor Martínez +# License LGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html + +from odoo.exceptions import AccessError +from odoo.tests import Form, common, new_test_user +from odoo.tests.common import users + +from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT + + +class TestCrmSecurity(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, **DISABLED_MAIL_CONTEXT)) + group_crm_all_leads = "crm_security_group.group_crm_all_leads" + group_sale_salesman_all_leads = "sales_team.group_sale_salesman_all_leads" + new_test_user( + cls.env, + login="crm_user", + groups=group_crm_all_leads, + ) + new_test_user( + cls.env, + login="sale_user", + groups=group_sale_salesman_all_leads, + ) + new_test_user( + cls.env, + login="crm_sale_user", + groups="%s,%s" % (group_crm_all_leads, group_sale_salesman_all_leads), + ) + cls.crm_menu = cls.env.ref("crm.crm_menu_root") + cls.sale_menu = cls.env.ref("sale.sale_menu_root") + # Force to active sale_menu_root (similar with sale_management installed) + cls.sale_menu.active = True + # create items to test after + cls.partner = cls.env["res.partner"].create({"name": "Test partner"}) + cls.crm_lead = cls.env["crm.lead"].sudo().create({"name": "Lead"}) + cls.sale_order = ( + cls.env["sale.order"].sudo().create({"partner_id": cls.partner.id}) + ) + + @users("crm_user") + def test_user_crm_only(self): + items = self.env["ir.ui.menu"]._visible_menu_ids() + self.assertIn(self.crm_menu.id, items) + self.assertNotIn(self.sale_menu.id, items) + # Crm lead checks + crm_lead = self.env["crm.lead"].browse(self.crm_lead.id) + with self.assertRaises(AccessError): + crm_lead.unlink() + crm_lead_form = Form(self.env["crm.lead"]) + crm_lead_form.name = "Lead" + crm_lead_form.save() + + @users("sale_user") + def test_user_sale(self): + items = self.env["ir.ui.menu"]._visible_menu_ids() + self.assertNotIn(self.crm_menu.id, items) + self.assertIn(self.sale_menu.id, items) + # Crm lead checks + crm_lead = self.env["crm.lead"].browse(self.crm_lead.id) + with self.assertRaises(AccessError): + crm_lead.unlink() + crm_lead_form = Form(self.env["crm.lead"]) + crm_lead_form.name = "Lead" + crm_lead_form.save() + # Sale order checks + sale_order = self.env["sale.order"].browse(self.sale_order.id) + with self.assertRaises(AccessError): + sale_order.unlink() + sale_order_form = Form(self.env["sale.order"]) + sale_order_form.partner_id = self.partner + sale_order_form.save() + + @users("crm_sale_user") + def test_user_crm_sale(self): + items = self.env["ir.ui.menu"]._visible_menu_ids() + self.assertIn(self.crm_menu.id, items) + self.assertIn(self.sale_menu.id, items) + # Crm lead checks + crm_lead = self.env["crm.lead"].browse(self.crm_lead.id) + with self.assertRaises(AccessError): + crm_lead.unlink() + crm_lead_form = Form(self.env["crm.lead"]) + crm_lead_form.name = "Lead" + crm_lead_form.save() + # Sale order checks + sale_order = self.env["sale.order"].browse(self.sale_order.id) + with self.assertRaises(AccessError): + sale_order.unlink() + sale_order_form = Form(self.env["sale.order"]) + sale_order_form.partner_id = self.partner + sale_order_form.save() diff --git a/crm_security_group/views/crm_lead_views.xml b/crm_security_group/views/crm_lead_views.xml new file mode 100644 index 00000000000..f42b93783b9 --- /dev/null +++ b/crm_security_group/views/crm_lead_views.xml @@ -0,0 +1,19 @@ + + + + crm.lead.oppor.inherited.crm + crm.lead + + + + + + + + diff --git a/crm_security_group/views/crm_team_views.xml b/crm_security_group/views/crm_team_views.xml new file mode 100644 index 00000000000..91179190be9 --- /dev/null +++ b/crm_security_group/views/crm_team_views.xml @@ -0,0 +1,90 @@ + + + + sales_team.team.view.kanban.dashboard.inherit.sale + crm.team + + + + + + + sale_crm.team.view.kanban.dashboard.inherit.sale + crm.team + + + + sales_team.group_sale_salesman + + + sales_team.group_sale_salesman + + + sales_team.group_sale_salesman + + + sales_team.group_sale_salesman + + + sales_team.group_sale_salesman + + + sales_team.group_sale_salesman + + + + + crm.team.view.kanban.dashboard.inherit.sale + crm.team + + + + crm_security_group.group_crm_own_leads + + + crm_security_group.group_crm_own_leads + + + crm_security_group.group_crm_own_leads + + + crm_security_group.group_crm_own_leads + + + crm_security_group.group_crm_own_leads + + + + diff --git a/crm_security_group/views/menu_items.xml b/crm_security_group/views/menu_items.xml new file mode 100644 index 00000000000..cad3b043d01 --- /dev/null +++ b/crm_security_group/views/menu_items.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + diff --git a/setup/crm_security_group/odoo/addons/crm_security_group b/setup/crm_security_group/odoo/addons/crm_security_group new file mode 120000 index 00000000000..3b506819509 --- /dev/null +++ b/setup/crm_security_group/odoo/addons/crm_security_group @@ -0,0 +1 @@ +../../../../crm_security_group \ No newline at end of file diff --git a/setup/crm_security_group/setup.py b/setup/crm_security_group/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/crm_security_group/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)