Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions website_payment_recurring_donations/controllers/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class PaymentPortal(payment_portal):
def donation_transaction(
self, amount, currency_id, partner_id, access_token, minimum_amount=0, **kwargs
):
if request.env.user._is_public():
kwargs["donation_partner_details"] = kwargs["partner_details"]
donation_frequency = kwargs.pop("donation_frequency", False)
context = request.env.context.copy()
context.update({"donation_frequency": donation_frequency})
if request.env.user._is_public():
context.update({"donation_partner_details": kwargs["partner_details"]})
request.env.context = context
Comment on lines +24 to 26
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kwargs["partner_details"] can raise a KeyError on this public JSON route if the client omits partner_details. Also, storing the full partner_details dict in env.context is risky in Odoo because context is typically a hashable (frozen) mapping used in cache keys; a nested dict value can trigger TypeError: unhashable type: 'dict' in downstream ORM/cache usage. Prefer extracting/storing only the primitive fields needed later (e.g., email/country_id/name) or serializing to a string/tuple, and use kwargs.get(...) with a guard.

Copilot uses AI. Check for mistakes.
return super().donation_transaction(
amount, currency_id, partner_id, access_token, minimum_amount, **kwargs
Expand Down Expand Up @@ -71,9 +71,9 @@ def _create_transaction(
custom_create_values["donation_frequency"] = request.env.context.get(
"donation_frequency"
)
if kwargs.get("donation_partner_details"):
if request.env.context.get("donation_partner_details", False):
res_partner_obj = request.env["res.partner"].sudo()
details = kwargs.pop("donation_partner_details")
details = request.env.context.get("donation_partner_details")
country_id = int(details.get("country_id"))
email = details.get("email")
partner_id = res_partner_obj.search(
Expand Down
Loading