Odoo Help

Welcome!

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.

1

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

By
Emanuel Cino
on 10/22/14, 5:45 AM 605 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 ?

1

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

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

deep
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)

Stats

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