Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Is this shortcut to call ORM methods valid in Odoo 7?

Emanuel Cino
on 10/22/14, 5:45 AM 581 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'})


    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 ?



| 5 4 7
Bangalore, India

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

On 10/24/14, 9:32 AM

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

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!

Emanuel Cino
on 10/27/14, 2:55 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 10/22/14, 5:45 AM
Seen: 581 times
Last updated: 3/16/15, 8:10 AM