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

StackOverflow https://stackoverflow.com/questions/18437202

  •  26-06-2022
  •  | 
  •  

Pregunta

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.

¿Fue útil?

Solución 2

self.pool.get is used to get the Singleton instance of the orm model from the registry pool for the database in use. self.browse is a method of the orm model to return a browse record.

As a rough analogy, think of self.pool.get as getting a database cursor and self.browse as a sql select of a records by Id. Note if you pass a browse an integer you get a single browse record, if you pass a list of ids you get a list of browse records.

Otros consejos

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

`

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top