diff --git a/odex25_base/partner_custom/models/models.py b/odex25_base/partner_custom/models/models.py index be5f1c3e8..37b097099 100644 --- a/odex25_base/partner_custom/models/models.py +++ b/odex25_base/partner_custom/models/models.py @@ -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'.")) \ No newline at end of file