From 85ae72a25bd3a3c451b3adb549b5cd4867846d51 Mon Sep 17 00:00:00 2001 From: jordyBSK Date: Fri, 25 Oct 2024 15:29:27 +0200 Subject: [PATCH 1/5] feat: Improved error messages for the forget_me method --- sponsorship_compassion/models/res_partner.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sponsorship_compassion/models/res_partner.py b/sponsorship_compassion/models/res_partner.py index 3608b1e16..ac147ced2 100644 --- a/sponsorship_compassion/models/res_partner.py +++ b/sponsorship_compassion/models/res_partner.py @@ -368,12 +368,24 @@ def forget_me(self): if "failure" in message.state: answer = message.get_answer_dict() if isinstance(answer, dict): - error_message = answer.get( - "DataProtection Error", message.failure_reason + # Get detailed error info + error_info = answer.get("Error", {}) + error_id = error_info.get("ErrorId", "N/A") + error_message = error_info.get("ErrorMessage", "Erreur inconnue") + error_time = error_info.get("ErrorTimeStamp", "Inconnu") + related_record = error_info.get("RelatedRecordId", "Non spécifié") + + # Format user-friendly error message + user_error_message = ( + f"an error occurred during data anonymisation.\n\n" + f"Message : {error_message}" ) else: - error_message = message.failure_reason - raise UserError(error_message) + user_error_message = ( + f"An internal error prevented the data from being anonymised.\n" + f"details: {message.failure_reason}" + ) + raise UserError(user_error_message) self.anonymize() # Reload the view return {"type": "ir.actions.client", "tag": "reload"} From 6152c23db60b35c3d78967784b41c88db2e81a55 Mon Sep 17 00:00:00 2001 From: jordyBSK Date: Fri, 25 Oct 2024 15:36:30 +0200 Subject: [PATCH 2/5] fix: remove unused error info --- sponsorship_compassion/models/res_partner.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sponsorship_compassion/models/res_partner.py b/sponsorship_compassion/models/res_partner.py index ac147ced2..3baa1ca64 100644 --- a/sponsorship_compassion/models/res_partner.py +++ b/sponsorship_compassion/models/res_partner.py @@ -368,12 +368,8 @@ def forget_me(self): if "failure" in message.state: answer = message.get_answer_dict() if isinstance(answer, dict): - # Get detailed error info error_info = answer.get("Error", {}) - error_id = error_info.get("ErrorId", "N/A") error_message = error_info.get("ErrorMessage", "Erreur inconnue") - error_time = error_info.get("ErrorTimeStamp", "Inconnu") - related_record = error_info.get("RelatedRecordId", "Non spécifié") # Format user-friendly error message user_error_message = ( From 824a91f543564949c4f545fdbbf97855fceb2614 Mon Sep 17 00:00:00 2001 From: jordyBSK Date: Thu, 21 Nov 2024 10:14:46 +0100 Subject: [PATCH 3/5] feat: add the translation to the various po files --- sponsorship_compassion/i18n/de.po | 36 +++++++++++++++----- sponsorship_compassion/i18n/fr_CH.po | 36 +++++++++++++++----- sponsorship_compassion/i18n/it.po | 36 +++++++++++++++----- sponsorship_compassion/models/res_partner.py | 2 +- 4 files changed, 85 insertions(+), 25 deletions(-) diff --git a/sponsorship_compassion/i18n/de.po b/sponsorship_compassion/i18n/de.po index 901ddd6c6..44ca8612f 100644 --- a/sponsorship_compassion/i18n/de.po +++ b/sponsorship_compassion/i18n/de.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: Compassion Odoo 14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-23 11:56+0000\n" +"POT-Creation-Date: 2024-11-21 08:52+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -10,13 +10,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.4.2\n" - -#. module: sponsorship_compassion -#: code:addons/sponsorship_compassion/models/res_partner.py:0 -#, python-format -msgid "1050 move lines" -msgstr "1050 Zeilen bewegen" +"X-Generator: Poedit 3.0.1\n" #. module: sponsorship_compassion #: model:ir.model,name:sponsorship_compassion.model_recurring_contract_group @@ -1564,12 +1558,25 @@ msgid "" "Unfortunately this sponsorship is already used, please choose a unique one" msgstr "Leider ist diese Patenschaft bereits vergeben, bitte wähle eine andere" +#. module: sponsorship_compassion +#: code:addons/sponsorship_compassion/models/res_partner.py:0 +#, python-format +msgid "Unknown error" +msgstr "Unbekannter Fehler" + #. module: sponsorship_compassion #: model:ir.model.fields,field_description:sponsorship_compassion.field_res_partner__unrec_items #: model:ir.model.fields,field_description:sponsorship_compassion.field_res_users__unrec_items msgid "Unrec Items" msgstr "Unerfasste Posten" +#. module: sponsorship_compassion +#: code:addons/sponsorship_compassion/models/res_partner.py:0 +#, fuzzy, python-format +#| msgid "Unrec Items" +msgid "Unreconciled Items" +msgstr "Unerfasste Posten" + #. module: sponsorship_compassion #: model:ir.model.fields,help:sponsorship_compassion.field_recurring_contract__hold_expiration_date msgid "Used for setting a hold after sponsorship cancellation" @@ -1662,6 +1669,15 @@ msgstr "" "Du solltest die Zahlungsoption mit \"1 Monat\" als wiederkehrenden Wert " "wählen" +#. module: sponsorship_compassion +#: model:ir.actions.server,name:sponsorship_compassion.sync_projects_from_gmc_cron_ir_actions_server +#: model:ir.cron,cron_name:sponsorship_compassion.sync_projects_from_gmc_cron +#: model:ir.cron,name:sponsorship_compassion.sync_projects_from_gmc_cron +msgid "" +"[T1715] Update FCPs from GMC automatically. Warning: very slow (multiple " +"hours)" +msgstr "" + #. module: sponsorship_compassion #: code:addons/sponsorship_compassion/models/contracts.py:0 #, python-format @@ -1673,6 +1689,10 @@ msgstr "jede" msgid "sub sponsorship" msgstr "SUB-Patenschaft" +#, python-format +#~ msgid "1050 move lines" +#~ msgstr "1050 Zeilen bewegen" + #~ msgid "Sponsored child code" #~ msgstr "Code für gesponsertes Kind" diff --git a/sponsorship_compassion/i18n/fr_CH.po b/sponsorship_compassion/i18n/fr_CH.po index c6dd042e6..f778477e4 100644 --- a/sponsorship_compassion/i18n/fr_CH.po +++ b/sponsorship_compassion/i18n/fr_CH.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: Compassion Odoo 14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-23 11:56+0000\n" +"POT-Creation-Date: 2024-11-21 08:52+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -10,13 +10,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.4.2\n" - -#. module: sponsorship_compassion -#: code:addons/sponsorship_compassion/models/res_partner.py:0 -#, python-format -msgid "1050 move lines" -msgstr "écritures du 1050" +"X-Generator: Poedit 3.0.1\n" #. module: sponsorship_compassion #: model:ir.model,name:sponsorship_compassion.model_recurring_contract_group @@ -1567,12 +1561,25 @@ msgstr "" "Malheureusement, ce parrainage est déjà utilisé, veuillez en choisir un " "autre." +#. module: sponsorship_compassion +#: code:addons/sponsorship_compassion/models/res_partner.py:0 +#, python-format +msgid "Unknown error" +msgstr "Erreur inconnue" + #. module: sponsorship_compassion #: model:ir.model.fields,field_description:sponsorship_compassion.field_res_partner__unrec_items #: model:ir.model.fields,field_description:sponsorship_compassion.field_res_users__unrec_items msgid "Unrec Items" msgstr "Enlever la réconciliation" +#. module: sponsorship_compassion +#: code:addons/sponsorship_compassion/models/res_partner.py:0 +#, fuzzy, python-format +#| msgid "Unrec Items" +msgid "Unreconciled Items" +msgstr "Enlever la réconciliation" + #. module: sponsorship_compassion #: model:ir.model.fields,help:sponsorship_compassion.field_recurring_contract__hold_expiration_date msgid "Used for setting a hold after sponsorship cancellation" @@ -1662,6 +1669,15 @@ msgstr "" "Vous devez sélectionner l'option de paiement avec \"1 mois\" comme valeur " "récurrente." +#. module: sponsorship_compassion +#: model:ir.actions.server,name:sponsorship_compassion.sync_projects_from_gmc_cron_ir_actions_server +#: model:ir.cron,cron_name:sponsorship_compassion.sync_projects_from_gmc_cron +#: model:ir.cron,name:sponsorship_compassion.sync_projects_from_gmc_cron +msgid "" +"[T1715] Update FCPs from GMC automatically. Warning: very slow (multiple " +"hours)" +msgstr "" + #. module: sponsorship_compassion #: code:addons/sponsorship_compassion/models/contracts.py:0 #, python-format @@ -1673,6 +1689,10 @@ msgstr "chaque" msgid "sub sponsorship" msgstr "reprise" +#, python-format +#~ msgid "1050 move lines" +#~ msgstr "écritures du 1050" + #~ msgid "Sponsored child code" #~ msgstr "Code de l'enfant parrainé" diff --git a/sponsorship_compassion/i18n/it.po b/sponsorship_compassion/i18n/it.po index 19f2ee9e3..b55d9eddd 100644 --- a/sponsorship_compassion/i18n/it.po +++ b/sponsorship_compassion/i18n/it.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: Compassion Odoo 14\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-05-23 11:56+0000\n" +"POT-Creation-Date: 2024-11-21 08:52+0000\n" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" @@ -10,13 +10,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.4.2\n" - -#. module: sponsorship_compassion -#: code:addons/sponsorship_compassion/models/res_partner.py:0 -#, python-format -msgid "1050 move lines" -msgstr "1050 linee di movimento" +"X-Generator: Poedit 3.0.1\n" #. module: sponsorship_compassion #: model:ir.model,name:sponsorship_compassion.model_recurring_contract_group @@ -1567,12 +1561,25 @@ msgstr "" "Purtroppo questa sponsorizzazione è già stata utilizzata, ti preghiamo di " "sceglierne una unica." +#. module: sponsorship_compassion +#: code:addons/sponsorship_compassion/models/res_partner.py:0 +#, python-format +msgid "Unknown error" +msgstr "Errore sconosciuto" + #. module: sponsorship_compassion #: model:ir.model.fields,field_description:sponsorship_compassion.field_res_partner__unrec_items #: model:ir.model.fields,field_description:sponsorship_compassion.field_res_users__unrec_items msgid "Unrec Items" msgstr "Voci non registrate" +#. module: sponsorship_compassion +#: code:addons/sponsorship_compassion/models/res_partner.py:0 +#, fuzzy, python-format +#| msgid "Unrec Items" +msgid "Unreconciled Items" +msgstr "Voci non registrate" + #. module: sponsorship_compassion #: model:ir.model.fields,help:sponsorship_compassion.field_recurring_contract__hold_expiration_date msgid "Used for setting a hold after sponsorship cancellation" @@ -1665,6 +1672,15 @@ msgstr "" "Devi selezionare l'opzione di pagamento con \"1 mese\" come valore " "ricorrente." +#. module: sponsorship_compassion +#: model:ir.actions.server,name:sponsorship_compassion.sync_projects_from_gmc_cron_ir_actions_server +#: model:ir.cron,cron_name:sponsorship_compassion.sync_projects_from_gmc_cron +#: model:ir.cron,name:sponsorship_compassion.sync_projects_from_gmc_cron +msgid "" +"[T1715] Update FCPs from GMC automatically. Warning: very slow (multiple " +"hours)" +msgstr "" + #. module: sponsorship_compassion #: code:addons/sponsorship_compassion/models/contracts.py:0 #, python-format @@ -1676,6 +1692,10 @@ msgstr "ogni" msgid "sub sponsorship" msgstr "Sostegno SUB" +#, python-format +#~ msgid "1050 move lines" +#~ msgstr "1050 linee di movimento" + #~ msgid "Sponsored child code" #~ msgstr "Codice bambino sponsorizzato" diff --git a/sponsorship_compassion/models/res_partner.py b/sponsorship_compassion/models/res_partner.py index 3baa1ca64..6a1a0e7ed 100644 --- a/sponsorship_compassion/models/res_partner.py +++ b/sponsorship_compassion/models/res_partner.py @@ -369,7 +369,7 @@ def forget_me(self): answer = message.get_answer_dict() if isinstance(answer, dict): error_info = answer.get("Error", {}) - error_message = error_info.get("ErrorMessage", "Erreur inconnue") + error_message = error_info.get("ErrorMessage", _("Unknown error")) # Format user-friendly error message user_error_message = ( From 78d36a16466cdf0f12447daa416adc5ffd7b1869 Mon Sep 17 00:00:00 2001 From: jordyBSK Date: Thu, 21 Nov 2024 11:36:00 +0100 Subject: [PATCH 4/5] feat: Add error logger for anonymization failures --- sponsorship_compassion/models/res_partner.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sponsorship_compassion/models/res_partner.py b/sponsorship_compassion/models/res_partner.py index 6a1a0e7ed..35ff7dd5c 100644 --- a/sponsorship_compassion/models/res_partner.py +++ b/sponsorship_compassion/models/res_partner.py @@ -16,6 +16,9 @@ from .contracts import SPONSORSHIP_TYPE_LIST +import logging + +_logger = logging.getLogger(__name__) # For more flexibility we have split "res.partner" by functionality # pylint: disable=R7980 @@ -376,11 +379,13 @@ def forget_me(self): f"an error occurred during data anonymisation.\n\n" f"Message : {error_message}" ) + _logger.error(error_message) else: user_error_message = ( f"An internal error prevented the data from being anonymised.\n" f"details: {message.failure_reason}" ) + _logger.error(f"Internal error: {message.failure_reason}") raise UserError(user_error_message) self.anonymize() # Reload the view From 52747a0dbd2832ef00553b691f4533905b26f5b8 Mon Sep 17 00:00:00 2001 From: jordyBSK Date: Thu, 21 Nov 2024 11:45:06 +0100 Subject: [PATCH 5/5] fix: fix res_partner files with pre-commit --- sponsorship_compassion/models/res_partner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sponsorship_compassion/models/res_partner.py b/sponsorship_compassion/models/res_partner.py index 35ff7dd5c..4b04e1bf4 100644 --- a/sponsorship_compassion/models/res_partner.py +++ b/sponsorship_compassion/models/res_partner.py @@ -8,6 +8,7 @@ # ############################################################################## import functools +import logging import random import string @@ -16,10 +17,9 @@ from .contracts import SPONSORSHIP_TYPE_LIST -import logging - _logger = logging.getLogger(__name__) + # For more flexibility we have split "res.partner" by functionality # pylint: disable=R7980 class ResPartner(models.Model):