Skip to Content
Menu
This question has been flagged
1 Reply
2069 Views

I try to pass a parameter in sql request but there is an error and i don't why. i post my code :

@api.onchange('x_exercice_id')

def changerExe(self):

val_exercice = int(self.x_exercice_id)

self.env.cr.execute("UPDATE ref_exercice SET actif = 'True' where id = %s" % (val_exercice,))

Thanks !

Avatar
Discard
Best Answer

Hi!

Try the following code :

@api.onchange('x_exercice_id')
def changerExe(self):
self.env.cr.execute("""UPDATE ref_exercice SET actif = 'True' where id = %s""" % (self.x_exercice_id.id,))

Best regards!


Avatar
Discard
Author

I try this but it doesn't worked. it brings me that error

psycopg2.ProgrammingError : Erreur : operator doesn't exit : integer = boolean

"""UPDATE ref_exercice SET actif = 'True' where id =False"""

however x_exercice_id is not a boolean but an integer

Sorry, I don't know that it was an integer field.

self.env.cr.execute("""UPDATE ref_exercice SET actif = 'True' where id = %s""" % (self.x_exercice_id,))

Sorry there is another error : No function matches the given name and the types of arguments. You must add explicit type conversions