Odoo Help

1

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

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

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

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