Hi all
I have checked the unique phone number validation with @api.constrains
class ResPartnerInherits(models.Model):
_inherit = 'res.partner'
@api.constrains('phone')
def _mobile_filed_validation(self):
for rec in self:
if rec.phone:
existing_partner = self.search([('phone', '=', rec.phone)])
if existing_partner:
raise ValidationError("A contact with the same phone number already exists.")
Im getting the output a validation error "A contact with the same phone number already exists." even though when I enter a unique phone number
What I have rectified here is even if i enter a unique phone number which doesn't exist in the database im getting the validation error and when I try to debug the code it gives me a res partner object (ex res.partner(930)) which doesnt exist in the database
Can anyone assist me in rectifying where the res_partner object with the id is getting stored
1. Cache/cookies/session/local storage of the browser
2. In some temporary table in the database