diff --git a/partner_risk_insurance_security/README.rst b/partner_risk_insurance_security/README.rst new file mode 100644 index 000000000..308b47ceb --- /dev/null +++ b/partner_risk_insurance_security/README.rst @@ -0,0 +1,93 @@ +=============================== +Partner Risk Insurance Security +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:a15148d51bb3109207bcfcc747b064f3c66b17366a2ef3e322f068b241da063e + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fcredit--control-lightgray.png?logo=github + :target: https://github.com/OCA/credit-control/tree/14.0/partner_risk_insurance_security + :alt: OCA/credit-control +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/credit-control-14-0/credit-control-14-0-partner_risk_insurance_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/credit-control&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module enhances credit policy control by making Credit Insurance fields read-only by default, +restricting editing capabilities to members of the 'Full Access to Credit Policy State' group. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Simply add the user to the 'Full Access to Credit Policy State' group +to enable editing of the 'Credit Insurance' fields that are otherwise read-only. + +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 +~~~~~~~ + +* Ooops404 +* toita86 + +Contributors +~~~~~~~~~~~~ + +* `Ooops404 `_: + * Eduard Brahas + +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-toita86| image:: https://github.com/toita86.png?size=40px + :target: https://github.com/toita86 + :alt: toita86 + +Current `maintainer `__: + +|maintainer-toita86| + +This module is part of the `OCA/credit-control `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_risk_insurance_security/__init__.py b/partner_risk_insurance_security/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/partner_risk_insurance_security/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/partner_risk_insurance_security/__manifest__.py b/partner_risk_insurance_security/__manifest__.py new file mode 100644 index 000000000..28a996b76 --- /dev/null +++ b/partner_risk_insurance_security/__manifest__.py @@ -0,0 +1,18 @@ +{ + "name": "Partner Risk Insurance Security", + "version": "14.0.1.0.0", + "summary": "Risk insurance partner information are accessible only" + "being part of the Full Access to Credit Policy State group", + "author": "Ooops404," "toita86," "Odoo Community Association (OCA)", + "license": "AGPL-3", + "application": False, + "website": "https://github.com/OCA/credit-control", + "depends": ["partner_risk_insurance"], + "category": "Credit Control", + "data": [ + "security/groups.xml", + "views/res_partner_view.xml", + ], + "installable": True, + "maintainers": ["toita86"], +} diff --git a/partner_risk_insurance_security/models/__init__.py b/partner_risk_insurance_security/models/__init__.py new file mode 100644 index 000000000..91fed54d4 --- /dev/null +++ b/partner_risk_insurance_security/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/partner_risk_insurance_security/models/res_partner.py b/partner_risk_insurance_security/models/res_partner.py new file mode 100644 index 000000000..7770f5958 --- /dev/null +++ b/partner_risk_insurance_security/models/res_partner.py @@ -0,0 +1,17 @@ +from odoo import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + is_full_access_user = fields.Boolean( + string="Is Full Access User", + compute="_compute_is_full_access_user", + store=False, + ) + + @api.depends_context("uid") + def _compute_is_full_access_user(self): + self.is_full_access_user = self.env.user.has_group( + "partner_risk_insurance_security.group_full_access_credit_policy_state" + ) diff --git a/partner_risk_insurance_security/readme/CONTRIBUTORS.rst b/partner_risk_insurance_security/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..a1b3eb687 --- /dev/null +++ b/partner_risk_insurance_security/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* `Ooops404 `_: + * Eduard Brahas diff --git a/partner_risk_insurance_security/readme/DESCRIPTION.rst b/partner_risk_insurance_security/readme/DESCRIPTION.rst new file mode 100644 index 000000000..41b618399 --- /dev/null +++ b/partner_risk_insurance_security/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module enhances credit policy control by making Credit Insurance fields read-only by default, +restricting editing capabilities to members of the 'Full Access to Credit Policy State' group. diff --git a/partner_risk_insurance_security/readme/USAGE.rst b/partner_risk_insurance_security/readme/USAGE.rst new file mode 100644 index 000000000..20f2acd9f --- /dev/null +++ b/partner_risk_insurance_security/readme/USAGE.rst @@ -0,0 +1,2 @@ +Simply add the user to the 'Full Access to Credit Policy State' group +to enable editing of the 'Credit Insurance' fields that are otherwise read-only. diff --git a/partner_risk_insurance_security/security/groups.xml b/partner_risk_insurance_security/security/groups.xml new file mode 100644 index 000000000..b68f73ac1 --- /dev/null +++ b/partner_risk_insurance_security/security/groups.xml @@ -0,0 +1,9 @@ + + + + + Full Access to Credit Insurance Fields + + + + diff --git a/partner_risk_insurance_security/static/description/index.html b/partner_risk_insurance_security/static/description/index.html new file mode 100644 index 000000000..a994fedc8 --- /dev/null +++ b/partner_risk_insurance_security/static/description/index.html @@ -0,0 +1,434 @@ + + + + + +Partner Risk Insurance Security + + + +
+

Partner Risk Insurance Security

+ + +

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

+

This module enhances credit policy control by making Credit Insurance fields read-only by default, +restricting editing capabilities to members of the ‘Full Access to Credit Policy State’ group.

+

Table of contents

+ +
+

Usage

+

Simply add the user to the ‘Full Access to Credit Policy State’ group +to enable editing of the ‘Credit Insurance’ fields that are otherwise read-only.

+
+
+

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

+
    +
  • Ooops404
  • +
  • toita86
  • +
+
+
+

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:

+

toita86

+

This module is part of the OCA/credit-control project on GitHub.

+

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

+
+
+
+ + diff --git a/partner_risk_insurance_security/static/icon.png b/partner_risk_insurance_security/static/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/partner_risk_insurance_security/static/icon.png differ diff --git a/partner_risk_insurance_security/tests/__init__.py b/partner_risk_insurance_security/tests/__init__.py new file mode 100644 index 000000000..217daae4d --- /dev/null +++ b/partner_risk_insurance_security/tests/__init__.py @@ -0,0 +1 @@ +from . import test_partner_risk_insurance_security diff --git a/partner_risk_insurance_security/tests/test_partner_risk_insurance_security.py b/partner_risk_insurance_security/tests/test_partner_risk_insurance_security.py new file mode 100644 index 000000000..c162241f5 --- /dev/null +++ b/partner_risk_insurance_security/tests/test_partner_risk_insurance_security.py @@ -0,0 +1,66 @@ +from odoo.tests.common import TransactionCase + + +class TestPartnerRiskInsuranceSecurity(TransactionCase): + def setUp(self): + super().setUp() + + # Create test users + self.full_access_user = self.env["res.users"].create( + { + "name": "Full Access User", + "login": "full_access_user", + "groups_id": [ + ( + 6, + 0, + [ + self.env.ref( + "partner_risk_insurance_security." + "group_full_access_credit_policy_state" + ).id + ], + ) + ], + } + ) + + self.regular_user = self.env["res.users"].create( + { + "name": "Regular User", + "login": "regular_user", + # No special groups assigned + } + ) + + # Create a test partner + self.partner = self.env["res.partner"].create( + {"name": "Test Partner", "company_type": "company"} + ) + + def test_is_full_access_user_field(self): + # Check with a user who has the full access group + self.env.user = self.full_access_user # Set the full access user + self.assertTrue( + self.env.user.has_group( + "partner_risk_insurance_security.group_full_access_credit_policy_state" + ) + ) + self.partner.invalidate_cache(["is_full_access_user"]) # Invalidate the cache + self.assertTrue( + self.partner.is_full_access_user, + "User with full access group should have `is_full_access_user` set to True", + ) + + # Check with a user who doesn't have the full access group + self.env.user = self.regular_user # Set the regular user + self.assertFalse( + self.env.user.has_group( + "partner_risk_insurance_security.group_full_access_credit_policy_state" + ) + ) + self.partner.invalidate_cache(["is_full_access_user"]) # Invalidate the cache + self.assertFalse( + self.partner.is_full_access_user, + "User without full access group should have `is_full_access_user` set to False", + ) diff --git a/partner_risk_insurance_security/views/res_partner_view.xml b/partner_risk_insurance_security/views/res_partner_view.xml new file mode 100644 index 000000000..780949bf9 --- /dev/null +++ b/partner_risk_insurance_security/views/res_partner_view.xml @@ -0,0 +1,63 @@ + + + + res.partner.form.risk_insurance_security + res.partner + + + + + {'readonly': [('is_full_access_user', '=', False)]} + + + {'readonly': [('is_full_access_user', '=', False)]} + + + {'readonly': [('is_full_access_user', '=', False)]} + + + {'readonly': [('is_full_access_user', '=', False)]} + + + {'readonly': [('is_full_access_user', '=', False)]} + + + {'readonly': [('is_full_access_user', '=', False)]} + + + {'readonly': [('is_full_access_user', '=', False)]} + + + {'readonly': [('is_full_access_user', '=', False)]} + + + + + + + diff --git a/setup/partner_risk_insurance_security/odoo/addons/partner_risk_insurance_security b/setup/partner_risk_insurance_security/odoo/addons/partner_risk_insurance_security new file mode 120000 index 000000000..5c4e7eeb9 --- /dev/null +++ b/setup/partner_risk_insurance_security/odoo/addons/partner_risk_insurance_security @@ -0,0 +1 @@ +../../../../partner_risk_insurance_security \ No newline at end of file diff --git a/setup/partner_risk_insurance_security/setup.py b/setup/partner_risk_insurance_security/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/partner_risk_insurance_security/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)