diff --git a/website_portal_restrict_modification/README.rst b/website_portal_restrict_modification/README.rst new file mode 100644 index 0000000..9e28229 --- /dev/null +++ b/website_portal_restrict_modification/README.rst @@ -0,0 +1,58 @@ +==================================== +Website Portal Restrict Modification +==================================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-beescoop%2Fobeesdoo-lightgray.png?logo=github + :target: https://github.com/beescoop/obeesdoo/tree/12.0/website_portal_restrict_modification + :alt: beescoop/obeesdoo + +|badge1| |badge2| |badge3| + +Prevent modification of sensible data by the users + +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Coop IT Easy SCRLfs + +Contributors +~~~~~~~~~~~~ + +* Rémy TAYMANS +* Vincent VAN ROSSEM + +Maintainers +~~~~~~~~~~~ + +This module is part of the `beescoop/obeesdoo `_ project on GitHub. + +You are welcome to contribute. diff --git a/website_portal_restrict_modification/__init__.py b/website_portal_restrict_modification/__init__.py new file mode 100644 index 0000000..e046e49 --- /dev/null +++ b/website_portal_restrict_modification/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/website_portal_restrict_modification/__manifest__.py b/website_portal_restrict_modification/__manifest__.py new file mode 100644 index 0000000..5ffe4fb --- /dev/null +++ b/website_portal_restrict_modification/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2017 - Today Coop IT Easy SCRLfs () +# - Rémy Taymans +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +{ + "name": "Website Portal Restrict Modification", + "version": "12.0.1.0.0", + "depends": ["portal", "website"], + "summary": """ + Portal extension preventing modification of sensible data by the users + """, + "author": "Coop IT Easy SCRLfs", + "license": "AGPL-3", + "website": "https://coopiteasy.be/", + "category": "Cooperative Management", + "data": ["views/portal_website_templates.xml"], + "installable": True, +} diff --git a/website_portal_restrict_modification/controllers/__init__.py b/website_portal_restrict_modification/controllers/__init__.py new file mode 100644 index 0000000..12a7e52 --- /dev/null +++ b/website_portal_restrict_modification/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/website_portal_restrict_modification/controllers/main.py b/website_portal_restrict_modification/controllers/main.py new file mode 100644 index 0000000..d1d0c34 --- /dev/null +++ b/website_portal_restrict_modification/controllers/main.py @@ -0,0 +1,34 @@ +# Copyright 2017 - Today Coop IT Easy SCRLfs () +# - Rémy Taymans +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + + +from odoo.addons.portal.controllers.portal import CustomerPortal + + +class CustomerPortalRestrictModification(CustomerPortal): + # override from `portal` module + CustomerPortal.MANDATORY_BILLING_FIELDS = [ + "city", + "country_id", + "phone", + "street", + "zipcode", + ] + CustomerPortal.OPTIONAL_BILLING_FIELDS = ["state_id"] + + def details_form_validate(self, data): + error, error_message = super().details_form_validate(data) + + # since we override mandatory and optional billing fields, + # parent method will insert the following key/value in `error` dict and `error_message` list, + # preventing from saving the form. Workaround is to remove them from both dict and list. + if ( + error.get("common") + and error["common"].lower() == "unknown field" + and any("unknown field" in s.lower() for s in error_message) + ): + error.pop("common") + error_message = [s for s in error_message if "unknown field" not in s.lower()] + + return error, error_message diff --git a/website_portal_restrict_modification/readme/CONTRIBUTORS.rst b/website_portal_restrict_modification/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..ff3ee17 --- /dev/null +++ b/website_portal_restrict_modification/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Rémy TAYMANS +* Vincent VAN ROSSEM diff --git a/website_portal_restrict_modification/readme/DESCRIPTION.rst b/website_portal_restrict_modification/readme/DESCRIPTION.rst new file mode 100644 index 0000000..53c34dc --- /dev/null +++ b/website_portal_restrict_modification/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Prevent modification of sensible data by the users diff --git a/website_portal_restrict_modification/static/description/index.html b/website_portal_restrict_modification/static/description/index.html new file mode 100644 index 0000000..f1ecf8f --- /dev/null +++ b/website_portal_restrict_modification/static/description/index.html @@ -0,0 +1,415 @@ + + + + + + +Website Portal Restrict Modification + + + +
+

Website Portal Restrict Modification

+ + +

Beta License: AGPL-3 beescoop/obeesdoo

+

Prevent modification of sensible data by the users

+

Table of contents

+ +
+

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 smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Coop IT Easy SCRLfs
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the beescoop/obeesdoo project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/website_portal_restrict_modification/views/portal_website_templates.xml b/website_portal_restrict_modification/views/portal_website_templates.xml new file mode 100644 index 0000000..0810362 --- /dev/null +++ b/website_portal_restrict_modification/views/portal_website_templates.xml @@ -0,0 +1,35 @@ + + + + + + + +