Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Improved error messages for the forget_me method #1987

Open
wants to merge 7 commits into
base: 14.0
Choose a base branch
from
16 changes: 12 additions & 4 deletions sponsorship_compassion/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,20 @@ 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
error_info = answer.get("Error", {})
error_message = error_info.get("ErrorMessage", "Erreur inconnue")
jordyBSK marked this conversation as resolved.
Show resolved Hide resolved

# Format user-friendly error message
user_error_message = (
f"an error occurred during data anonymisation.\n\n"
jordyBSK marked this conversation as resolved.
Show resolved Hide resolved
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"}
Expand Down
Loading