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.

2

Where is pool.get() defined in OpenERP source?

By
Antanas
on 4/24/13, 3:55 AM 5,359 views

By looking at addons, that come with OpenERP source, one can tell that

self.pool.get('model.name')

is frequently used in model methods.

Where is this "pool" and "get()" defined in OpenERP source code? I would like to look at it's documentation (docstrings).

1
xingtongjie
On 8/18/13, 2:05 AM

In /server/openerp/osv/orm.py

class BaseModel(object):

def __init__(self, pool, cr):

    """ Initialize a model and make it part of the given registry.

    - copy the stored fields' functions in the osv_pool,
    - update the _columns with the fields found in ir_model_fields,
    - ensure there is a many2one for each _inherits'd parent,
    - update the children's _columns,
    - give a chance to each field to initialize itself.

    """
    pool.add(self._name, self)
    self.pool = pool

pool is registry

in /server/openerp/pooler.py

def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False):

"""Create and return a database connection and a newly initialized registry."""

 registry = RegistryManager.get(db_name, force_demo, status, update_module)

return registry.db, registry

/server/openerp/modules/registry.py

class Registry(object): """ Model registry for a particular database.

The registry is essentially a mapping between model names and model
instances. There is one registry instance per database.

"""

def __init__(self, db_name):
    self.models = {}    # model name/model instance mapping

def get(self, model_name):

    """ Return a model for a given name or None if it doesn't exist."""

    return self.models.get(model_name)

I understand pool today, above i find pool 's source code.

the pool is pool of module`s instance

xingtongjie
on 12/14/14, 8:17 AM

Has nothing to do with db cursor, every model has its cr. realize 'read(),write() etc 'fuction operation.

xingtongjie
on 12/14/14, 8:20 AM

Where init module, the pool is passed into module.

xingtongjie
on 12/14/14, 8:23 AM
0

Andreas Maertens

--Andreas Maertens--
912
| 5 5 7
Finsterwalde, Germany
--Andreas Maertens--

I develop odoo8.0 modules

Andreas Maertens
On 4/24/13, 8:48 AM

/server/openerp/pooler.py

Did you find it there?

Andreas Maertens
on 5/3/13, 11:04 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: 4/24/13, 3:55 AM
Seen: 5359 times
Last updated: 7/11/16, 11:40 PM