在openerp开发中有什么不同的self.browse和self.pool.get?

时间:2023-01-31 20:23:58

I have been working on developing a module in openerp-7.0. I have been using python and eclipse IDE for development. I wanted to know the difference bw self.browse and self.pool.get in openerp development . Plz reply me as soon as possible.

我一直在开发openerp-7.0中的模块。我一直在使用python和eclipse IDE进行开发。我想知道在openerp开发中bw self.browse和self.pool.get的区别。 Plz尽快回复我。

Thanks. Best wishes Hopes for suggestion

谢谢。祝愿建议

2 个解决方案

#1


6  

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.

self.pool.get用于从正在使用的数据库的注册表池中获取orm模型的Singleton实例。 self.browse是orm模型返回浏览记录的方法。

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.

作为一个粗略的类比,将self.pool.get视为获取数据库游标,并将self.browse视为按Id读取记录的sql。请注意,如果您传递一个浏览整数,则会获得单个浏览记录,如果您传递一个ID列表,则会获得一个浏览记录列表。

#2


15  

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

要按ID访问记录,您需要使用ORM的浏览方法

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

您可以在同一个类中编写一个方法,当您想要浏览其记录但是如果您想要浏览另一个类的记录时,在这种情况下,您首先需要使用self.pool.get('another.class)创建该类的实例。 ')然后你可以浏览它

eg :

例如:

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

`

`

#1


6  

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.

self.pool.get用于从正在使用的数据库的注册表池中获取orm模型的Singleton实例。 self.browse是orm模型返回浏览记录的方法。

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.

作为一个粗略的类比,将self.pool.get视为获取数据库游标,并将self.browse视为按Id读取记录的sql。请注意,如果您传递一个浏览整数,则会获得单个浏览记录,如果您传递一个ID列表,则会获得一个浏览记录列表。

#2


15  

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

要按ID访问记录,您需要使用ORM的浏览方法

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

您可以在同一个类中编写一个方法,当您想要浏览其记录但是如果您想要浏览另一个类的记录时,在这种情况下,您首先需要使用self.pool.get('another.class)创建该类的实例。 ')然后你可以浏览它

eg :

例如:

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

`

`