Skip to content

Commit

Permalink
[IMP] website_event_attendee_fields: при поиске контакта по почте в п…
Browse files Browse the repository at this point in the history
…риоритет брать контакт текущего пользователя
  • Loading branch information
em230418 committed Dec 26, 2024
1 parent 9b00f4e commit 6b96c70
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions website_event_attendee_fields/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ def check_email(self, event_id, email):
if not email:
return {}

partner = (
request.env["res.partner"].sudo().search([("email", "=", email)], limit=1)
)
Partners = request.env["res.partner"].sudo()

current_user = request.env.user
if email == current_user.email:
partner = current_user.partner_id
else:
partner = Partners.search([("email", "=", email)], limit=1)

if not partner:

def remove_spaces(s):
Expand All @@ -69,19 +74,15 @@ def remove_spaces(s):
return s

email = remove_spaces(email)
partner = (
request.env["res.partner"]
.sudo()
.search(
[
"|",
"|",
("email", "=ilike", "% " + email),
("email", "=ilike", "% " + email + " %"),
("email", "=ilike", email + " %"),
],
limit=1,
)
partner = Partners.search(
[
"|",
"|",
("email", "=ilike", "% " + email),
("email", "=ilike", "% " + email + " %"),
("email", "=ilike", email + " %"),
],
limit=1,
)
if not partner:
return {}
Expand Down Expand Up @@ -111,7 +112,7 @@ def remove_spaces(s):
value = getattr(partner, fname) or ""

if fname and value:
if partner == request.env.user.partner_id:
if partner == current_user.partner_id:
known_fields[fname] = value
else:
known_fields[fname] = ""
Expand Down

0 comments on commit 6b96c70

Please sign in to comment.