Merge pull request #4831 from expsa/ENS-3799

[IMP] odex_benefit: search for partner before creating
This commit is contained in:
abdurrahman-saber 2025-10-08 09:26:44 +03:00 committed by GitHub
commit 46f5008270
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -62,9 +62,12 @@ class CreatePortalAccount(http.Controller):
'name': f'{first_name} {second_name}',
'email': email,
'phone': formatted_phone,
# 'account_type': account_type,
}
partner = Partner.create(partner_vals)
partner = Partner.search([('phone', '=like', f'%{formatted_phone}')], limit=1)
if not partner:
partner = Partner.create(partner_vals)
else:
partner.write(partner_vals)
# Create user and link to partner (no reset password)
Users = request.env['res.users'].sudo()