I'm tryng to validate a field, so I've written this code:
@api.one
@api.constrains('code')
def control_code(self):
i=0
a=1
while i<9:
if i==0:
if unicode.isdigit(self.code[0]):
a=i+1
raise Warning(("Warning!\nThe character %s must be a letter") % (a))
elif i in range (1,4) or i in range (5,10):
if not unicode.isdigit(self.code[i]):
raise Warning(('Warning!\nThe character %s must be a number') % (a))
elif i == 4:
if self.code[i] is not '/':
raise Warning(("Warning!\nThe character %s must be '/'") % (a))
i=i+1
a=a+1
Everything works fine, except for i==4. Even if I put a '/', I get the warning message.
Anyone knows why?