跳至内容
菜单
此问题已终结
1 回复
1218 查看
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)

形象
丢弃
最佳答案

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

形象
丢弃
相关帖文 回复 查看 活动
2
2月 22
4431
1
9月 21
2354
1
4月 15
21984
2
12月 22
3086
0
10月 21
1691