performance fix

Now, we get all the values that we need from ir.model.data before the
loop. It's better, but I'm pretty sure we can do more on this way.