Session¶
-
class
connector.session.
ConnectorSession
(cr, uid, context=None)[source]¶ Bases:
object
Container for the OpenERP transactional stuff:
-
env
¶ The Environment
-
cr
¶ The OpenERP Cursor
-
uid
¶ The User ID as integer
-
pool
¶ The registry of models
-
context
¶ The current OpenERP’s context
-
change_context
(**kwds)[source]¶ Context Manager: create a new Env with an updated context
It generates a new
openerp.api.Environment
used within the context manager, where the context is extended with the arguments. The original environment is restored at the closing of the context manager.The extended context is either the provided
context
in whichoverrides
are merged or the current context in whichoverrides
are merged e.g.# current context is {'key1': True} r2 = records.with_context({}, key2=True) # -> r2._context is {'key2': True} r2 = records.with_context(key2=True) # -> r2._context is {'key1': True, 'key2': True}
Warning
only recordsets read within the context manager will be attached to this environment. In many cases, you will prefer to use
openerp.models.BaseModel.with_context()
-
change_user
(**kwds)[source]¶ Context Manager: create a new Env with the specified user
It generates a new
openerp.api.Environment
used within the context manager, where the user is replaced by the specified one. The original environment is restored at the closing of the context manager.Warning
only recordsets read within the context manager will be attached to this environment. In many cases, you will prefer to use
openerp.models.BaseModel.with_context()
-
context
-
cr
-
is_module_installed
(module_name)[source]¶ Indicates whether a module is installed or not on the current database.
Use a convention established for the connectors addons: To know if a module is installed, it looks if an (abstract) model with name
module_name.installed
is loaded in the registry.
-
pool
-
search
(model, domain, limit=None, offset=0, order=None)[source]¶ Shortcut to
openerp.models.BaseModel.search
-
uid
-
-
class
connector.session.
ConnectorSessionHandler
(db_name, uid, context=None)[source]¶ Bases:
object
Allow to create a new instance of
ConnectorSession
for a database.-
db_name
¶ The name of the database we’re working on
-
uid
¶ The User ID as integer
-
context
¶ The current OpenERP’s context
Usage:
session_hdl = ConnectorSessionHandler(db_name, 1) with session_hdl.session() as session: # work with session
-