forked from Smile-SA/odoo_addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] Add module smile_anonymize_partner
This module helps to anonymize personal data of a partner.
- Loading branch information
1 parent
8ffeb8f
commit d37a37c
Showing
16 changed files
with
883 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
======================== | ||
Smile Anonymize Partner | ||
======================== | ||
|
||
.. |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-Smile_SA%2Fodoo_addons-lightgray.png?logo=github | ||
:target: https://github.com/Smile-SA/odoo_addons/tree/12.0/smile_anonymize_partner | ||
:alt: Smile-SA/odoo_addons | ||
|
||
|badge2| |badge3| | ||
|
||
This module anonymize the personal data of partners. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
* To change fields to anonymized you should surcharge method get_anonymize_fields() that return a dictionary with 3 keys: fields, phones and emails with a list of fields for each. | ||
Default values: {'fields': ['name', 'street', 'street2', 'comment'], 'phones': ['phone', 'mobile'], 'emails': ['email']} | ||
* To anonymize personal data of your partners you should call action: action_anonymization(). This method display a popup with a warning that this action is irreversible and the Yes/Cancel buttons. | ||
* When record is anonymized the boolean is_anonymized get as value True and the partner is archived (call method toggle_active()). | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/Smile-SA/odoo_addons/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 | ||
`here <https://github.com/Smile-SA/odoo_addons/issues/new?body=module:%20smile_base%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
GDPR / EU Privacy | ||
================= | ||
|
||
This addons does not collect any data and does not set any browser cookies. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Smile SA | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Laila ERAMI | ||
* Stéphanie MARCU | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the Smile SA. | ||
|
||
Since 1991 Smile has been a pioneer of technology and also the European expert in open source solutions. | ||
|
||
.. image:: https://avatars0.githubusercontent.com/u/572339?s=200&v=4 | ||
:alt: Smile SA | ||
:target: http://smile.fr | ||
|
||
This module is part of the `odoo-addons <https://github.com/Smile-SA/odoo_addons>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Smile Anonymize Partner", | ||
"version": "0.0.1", | ||
"depends": ['base'], | ||
"author": "Smile", | ||
"license": 'AGPL-3', | ||
"description": """ | ||
Smile Anonymize Partner: | ||
------------------------ | ||
This module anonymize the personal data of partners .\n | ||
Use:\n | ||
- To change fields to anonymized you should surcharge | ||
method get_anonymize_fields() that return a dictionary | ||
with 3 keys: fields, phones and emails with a list of fields for each.\n | ||
Default values: { | ||
'fields': ['name', 'street', 'street2', 'comment'], | ||
'phones': ['phone', 'mobile'], | ||
'emails': ['email'] | ||
}\n | ||
- To anonymize personal data of your partners you should call action: | ||
action_anonymization(). This method display a popup with a warning | ||
that this action is irreversible and the Yes/Cancel buttons.\n | ||
- When record is anonymized the boolean is_anonymized get as value True.\n | ||
""", | ||
"summary": "", | ||
"website": "", | ||
"category": 'Tools', | ||
"sequence": 20, | ||
"data": [ | ||
'security/smile_anonymize_partner_security.xml', | ||
'views/res_partner_views.xml', | ||
'wizard/confirm_anonymization_view.xml', | ||
], | ||
"auto_install": False, | ||
"installable": True, | ||
"application": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * smile_anonymize_partner | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-11-27 08:46+0000\n" | ||
"PO-Revision-Date: 2019-11-27 08:46+0000\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: smile_anonymize_partner | ||
#: model:res.groups,name:smile_anonymize_partner.group_anonymize_member | ||
msgid "Anonymize partner Infos" | ||
msgstr "Anonymiser les données personnelles des partenaires" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model_terms:ir.ui.view,arch_db:smile_anonymize_partner.confirm_anonymization_wizard | ||
msgid "Be careful, this action is irreversible. Do you want to continue ?" | ||
msgstr "Attention, cette action est irréversible. Voulez vous continuer ?" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model_terms:ir.ui.view,arch_db:smile_anonymize_partner.confirm_anonymization_wizard | ||
msgid "Cancel" | ||
msgstr "Annuler" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model,name:smile_anonymize_partner.model_confirm_anonymization | ||
msgid "Confirm anonymization" | ||
msgstr "Confirmer l'anonymisation" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model,name:smile_anonymize_partner.model_res_partner | ||
msgid "Contact" | ||
msgstr "" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_confirm_anonymization__create_uid | ||
msgid "Created by" | ||
msgstr "Créé par" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_confirm_anonymization__create_date | ||
msgid "Created on" | ||
msgstr "Créé le" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_confirm_anonymization__display_name | ||
msgid "Display Name" | ||
msgstr "Nom affiché" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_confirm_anonymization__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_res_partner__is_anonymized | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_res_users__is_anonymized | ||
msgid "Is Anonymized" | ||
msgstr "Est anonymisé" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_confirm_anonymization____last_update | ||
msgid "Last Modified on" | ||
msgstr "Dernière modification le" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_confirm_anonymization__write_uid | ||
msgid "Last Updated by" | ||
msgstr "Dernière mise à jour par" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model:ir.model.fields,field_description:smile_anonymize_partner.field_confirm_anonymization__write_date | ||
msgid "Last Updated on" | ||
msgstr "Dernière mise à jour le" | ||
|
||
#. module: smile_anonymize_partner | ||
#: model_terms:ir.ui.view,arch_db:smile_anonymize_partner.confirm_anonymization_wizard | ||
msgid "Yes" | ||
msgstr "Oui" | ||
|
||
#. module: smile_anonymize_partner | ||
#: code:addons/smile_anonymize_partner/models/res_partner.py:23 | ||
#, python-format | ||
msgid "You don't have access to do this action. Please contact your system administrator." | ||
msgstr "Vous n'avez pas les droits pour faire cette action. Veuillez contacter votre administrateur système." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import anonymization | ||
from . import res_partner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.eu>) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
|
||
def anonymise_emails(record_id, fields): | ||
return ', '.join( | ||
map(lambda field: | ||
"%s=case when %s is null or %s='' then %s " | ||
"else '%s%[email protected]' end" % ( | ||
field.replace("'", ''), field.replace( | ||
"'", ''), field.replace("'", ''), field.replace("'", ''), | ||
field.replace("'", ''), record_id), fields)) | ||
|
||
|
||
def anonymise_phones(fields): | ||
return ', '.join( | ||
map(lambda field: | ||
"%s=case when %s is null or %s='' then %s " | ||
"else '+33000000000' end" % ( | ||
field.replace("'", ''), field.replace("'", ''), | ||
field.replace("'", ''), field.replace("'", '')), fields)) | ||
|
||
|
||
def anonymise_fields(record_id, fields): | ||
return ', '.join( | ||
map(lambda field: "%s=case when %s is null or %s='' then %s " | ||
"else '%s%s-anonym' end" % ( | ||
field.replace("'", ''), field.replace( | ||
"'", ''), field.replace("'", ''), field.replace("'", ''), | ||
field.replace("'", '')[:7], record_id), fields)) | ||
|
||
|
||
def is_anonymised_fields(fields): | ||
return ', '.join( | ||
map(lambda field: "%s=True" % field.replace("'", ''), fields)) | ||
|
||
|
||
def anonymise_object( | ||
self, table, record_id, fields_list=None, | ||
phones_list=None, email_list=None): | ||
anonymised_vals = '' | ||
if fields_list: | ||
anonymised_vals = anonymise_fields(record_id, fields_list) | ||
if phones_list: | ||
anonymised_vals = anonymised_vals and '%s, %s' % ( | ||
anonymised_vals, anonymise_phones(phones_list) | ||
) or anonymise_phones(phones_list) | ||
if email_list: | ||
anonymised_vals = anonymised_vals and '%s, %s' % ( | ||
anonymised_vals, anonymise_emails(record_id, email_list) | ||
) or anonymise_emails(record_id, email_list) | ||
query = 'update {table} set {values} where id = {record_id}'.format( | ||
table=table, values=anonymised_vals, record_id=record_id) | ||
self._cr.execute(query) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# (C) 2019 Smile (<http://www.smile.fr>) | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
|
||
from odoo import api, fields, models, _ | ||
from odoo.exceptions import AccessError | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = 'res.partner' | ||
|
||
is_anonymized = fields.Boolean('Is Anonymized') | ||
|
||
def get_anonymize_fields(self): | ||
return {'fields': ['name', 'street', 'street2', 'comment'], | ||
'phones': ['phone', 'mobile'], | ||
'emails': ['email']} | ||
|
||
@api.multi | ||
def action_anonymization(self): | ||
if not self.env.user.has_group( | ||
'smile_anonymize_partner.group_anonymize_partner'): | ||
raise AccessError( | ||
_("You don't have access to do this action. " | ||
"Please contact your system administrator.")) | ||
return { | ||
'type': 'ir.actions.act_window', | ||
'res_model': 'confirm.anonymization', | ||
'view_mode': 'form', | ||
'view_type': 'form', | ||
'view_id': self.env.ref( | ||
'smile_anonymize_partner.confirm_anonymization_wizard').id, | ||
'target': 'new', | ||
'context': {'active_ids': self.ids}, | ||
} |
11 changes: 11 additions & 0 deletions
11
smile_anonymize_partner/security/smile_anonymize_partner_security.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<data noupdate="1"> | ||
|
||
<record id="group_anonymize_partner" model="res.groups"> | ||
<field name="name">Anonymize partner Infos</field> | ||
<field name="implied_ids" eval="[(4, ref('base.group_partner_manager'))]"/> | ||
</record> | ||
|
||
</data> | ||
</odoo> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.