Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between self.browse() and self.pool.get() in OpenERP development?

Tags:

python

odoo

I have been working on developing a module in OpenERP 7.0. I have been using Python and the Eclipse IDE for development. I wanted to know the difference between self.browse() and self.pool.get() in OpenERP development.

Thanks.

like image 779
arsalan.jawed Avatar asked Nov 29 '22 08:11

arsalan.jawed


1 Answers

To access a record by id you need you use ORM's browse method

def some_moethod(self, cr, uid, ids):
    self.browse(cr, uid, ids) // same class
    do_some_Stuff
    return something

You can use when you are writing a method in same class whose records you want browse but if you want browse records from another class, In this case first you need to create instance of that class using self.pool.get('another.class') then you can browse on it

eg :

def some_moethod(self, cr, uid, ids):
    self.pool.get('another.class').browse(cr, uid, ids)
    do_some_Stuff
    return something

`

like image 117
StackUP Avatar answered Dec 06 '22 10:12

StackUP