Your column names do not match within your script.
id = self.data.getValueAt(rowIndex, 'idreferencia') query = 'UPDATE stock SET %s = ? WHERE idreferencia = ?' % (colName)