Merge pull request #1899 from expsa/051224_odex25_base

051224 odex25 base
This commit is contained in:
Hamed-exp 2024-12-09 08:53:13 +02:00 committed by GitHub
commit c28b4537a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 2 deletions

View File

@ -2,8 +2,7 @@ import base64
import re
from odoo import models, fields, api, exceptions, tools, _
from datetime import datetime, date, timedelta
from odoo.exceptions import Warning
from odoo.exceptions import Warning, ValidationError
from odoo.modules.module import get_module_resource
class ResPartner(models.Model):
@ -45,3 +44,18 @@ class ResPartner(models.Model):
if date.today() >= each.identification_expiry_date:
raise Warning(_("Error, the expiry date must be greater than the date of the day"))
@api.constrains('phone')
def _check_phone_length_and_digits(self):
for record in self:
if record.phone:
if not record.phone.isdigit() or len(record.phone) != 7:
raise ValidationError(_("The phone number must contain exactly 7 digits and no letters or symbols."))
@api.constrains('email')
def _check_email_format(self):
for record in self:
if record.email:
if '@' not in record.email or not record.email.endswith('.com'):
raise ValidationError(_("The email address must contain '@' and end with '.com'."))