This question has been flagged
1 Reply
2494 Views

Let's say you have in your code an object of model 'account.invoice' and inside a method you want to update the partner. I noticed that you have two ways of calling the 'write' method on model 'res.partner'. You could either do :

    invoice.partner_id.write({'name': 'Mister Test'})

OR

    partner_obj = self.pool.get('res.partner') partner_obj.write(cr, uid, invoice.partner_id.id, {'name': 'Mister Test'})

I always used the second way because it is the one that is always described in documentations. However, I discovered that the first way is also working and is shorter. Is it ok to do so ?

Avatar
Discard
Best Answer

Yes it is perfectly ok... you can use either way

Avatar
Discard
Author

I miss some further explanations on the difference (performance?) but I will accept this if no one else can explain it. The point is that the first way is explained nowhere... Anyways, thanks for your answer!