Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
1231 Ansichten
Hello, I would like to know how I could execute this query only for one record and not have it executed on the entire table.




if record.x_disponibilidad and not record.x_aprobacion:

      query = "update x_reg_asignaciones set x_aprobacion = 12550"

      self.env.cr.execute(query)

Avatar
Verwerfen
Beste Antwort

Hi,

If you want to execute the query only for a specific record and not on the entire table, you can modify the query to include a 'WHERE' clause that filters the records based on some criteria, such as the record ID. Here's how you can do it:

if record.x_disponibilidad and not record.x_aprobacion:

    query = "UPDATE x_reg_asignaciones SET x_aprobacion = 12550 WHERE id = %s"

    self.env.cr.execute(query, (record.id,))

WHERE id = %s filters the records to update based on the ID column matching the ID of the specific record .%s is a placeholder for the record ID.


Hope it helps

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Feb. 22
4455
1
Sept. 21
2364
1
Apr. 15
21987
2
Dez. 22
3096
0
Okt. 21
1691