Skip to content

[FIX] website_membership_registration: Update _check_mail_unique to use sql query instead of search to avoid maximum recursion depth issue#139

Merged
ByteMeAsap merged 1 commit into
18.0from
18.0-fix-website_membership_registration
Apr 29, 2026
Merged

[FIX] website_membership_registration: Update _check_mail_unique to use sql query instead of search to avoid maximum recursion depth issue#139
ByteMeAsap merged 1 commit into
18.0from
18.0-fix-website_membership_registration

Conversation

@ByteMeAsap
Copy link
Copy Markdown
Contributor

No description provided.

…se sql query instead of search to avoid maximum recursion depth issue
Copilot AI review requested due to automatic review settings April 29, 2026 12:09
@ByteMeAsap ByteMeAsap merged commit 7efe410 into 18.0 Apr 29, 2026
2 of 4 checks passed
@ByteMeAsap ByteMeAsap deleted the 18.0-fix-website_membership_registration branch April 29, 2026 12:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the website_membership_registration email uniqueness constraint to avoid recursion by replacing an ORM search() with a direct SQL query when checking for existing member partners.

Changes:

  • Reworked _check_mail_unique to use cr.execute() against res_partner for the “existing member” email check.
  • Kept the “existing user login” uniqueness check via ORM search.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.env.cr.execute(
"""
SELECT id FROM res_partner
WHERE email ILIKE %s
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

The SQL condition email ILIKE %s treats % and _ in the provided email as wildcards (e.g., underscores are common in emails). That can cause false positives compared to Odoo's =ilike domain operator (which escapes wildcards for exact matching). Consider switching to an equality-based comparison such as LOWER(email) = LOWER(%s) (or explicitly escaping LIKE wildcards and adding an ESCAPE clause) to preserve exact-match semantics.

Suggested change
WHERE email ILIKE %s
WHERE LOWER(email) = LOWER(%s)

Copilot uses AI. Check for mistakes.
SELECT id FROM res_partner
WHERE email ILIKE %s
AND id != %s
AND membership_state != 'none'
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

This direct SQL query bypasses Odoo's usual active_test filtering. Previously, self.search(...) would (by default) ignore archived partners, but the SQL will match inactive records too, potentially blocking reuse of an email that only exists on an archived member. If the old behavior is desired, add an AND active (or equivalent) predicate to the SQL to align with the ORM search semantics.

Suggested change
AND membership_state != 'none'
AND membership_state != 'none'
AND active

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants