[IMP] odex_benefit: change login message

This commit is contained in:
Abdurrahman Saber 2025-10-08 09:14:41 +03:00
parent 241d5de0e3
commit 5a429ea3ec
2 changed files with 13 additions and 3 deletions

View File

@ -1,4 +1,4 @@
from odoo import http
from odoo import http, _
from odoo.http import request
from odoo.addons.phone_validation.tools import phone_validation
@ -32,9 +32,19 @@ class CreatePortalAccount(http.Controller):
# Check if user already exists with the same otp_mobile_phone
existing_user = request.env['res.users'].sudo().search([('login', '=', login)], limit=1)
if existing_user:
existing_partner = existing_user.partner_id
is_family_or_beneficiary = existing_partner.is_family or existing_partner.is_benefit
is_donor_vendor_sponsor = existing_partner.is_donor or existing_partner.is_sponsor_portal or existing_partner.is_vendor
if is_family_or_beneficiary and account_type == 'donor':
message = _("This phone number is already registered as Family/Beneficiary and cannot be used for sponsor account!")
elif is_donor_vendor_sponsor and account_type == 'family':
message = _("This phone number is already registered as Donor/Sponsor and cannot be used for family account!")
else:
message = _('This phone number is already registered. Please use a different phone number.')
data = {
'status': False,
'message': 'This phone number is already registered. Please use a different phone number.'
'message': message
}
return json.dumps(data)

View File

@ -17,4 +17,4 @@ class ResPartner(models.Model):
is_donor_vendor_sponsor = rec.is_donor or rec.is_sponsor_portal or rec.is_vendor
if is_family_or_beneficiary and is_donor_vendor_sponsor:
raise ValidationError(_("A contact cannot be both Family/Beneficiary and Donor/Member/Sponsor at the same time"))
raise ValidationError(_("A contact cannot be both Family/Beneficiary and Donor/Member/Sponsor at the same time!"))