Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cls._name, method, args, kwargs)
return result
return rpc_method
def __repr__(cls):
return "Model(%r)" % (cls._name)
@property
def env(cls):
"""The environment used for this model/recordset."""
return cls._env
# An intermediate class used to associate the 'MetaModel' metaclass to the
# 'Model' one with a Python 2 and Python 3 compatibility
BaseModel = MetaModel('BaseModel', (), {})
class Model(BaseModel):
"""Base class for all data model proxies.
.. note::
All model proxies (based on this class) are generated by an
:class:`environment `
(see the :attr:`odoorpc.ODOO.env` property).
.. doctest::
:options: +SKIP
>>> import odoorpc
>>> odoo = odoorpc.ODOO('localhost', port=8069)
>>> odoo.login('db_name', 'admin', 'password')
def __getattr__(cls, method):
"""Provide a dynamic access to a RPC method."""
if method.startswith('_'):
return super(MetaModel, cls).__getattr__(method)
def rpc_method(*args, **kwargs):
"""Return the result of the RPC request."""
if cls._odoo.config['auto_context'] and 'context' not in kwargs:
kwargs['context'] = cls.env.context
result = cls._odoo.execute_kw(cls._name, method, args, kwargs)
return result
return rpc_method
def __getattr__(cls, method):
"""Provide a dynamic access to a RPC method."""
if method.startswith('_'):
return super(MetaModel, cls).__getattr__(method)
def rpc_method(*args, **kwargs):
"""Return the result of the RPC request."""
if cls._odoo.config['auto_context'] \
and 'context' not in kwargs:
kwargs['context'] = cls._odoo.env.context
result = cls._odoo.execute_kw(
cls._name, method, args, kwargs)
return result
return rpc_method
return result
return rpc_method
def __repr__(cls):
return "Model(%r)" % (cls._name)
@property
def env(cls):
"""The environment used for this model/recordset."""
return cls._env
# An intermediate class used to associate the 'MetaModel' metaclass to the
# 'Model' one with a Python 2 and Python 3 compatibility
BaseModel = MetaModel('BaseModel', (), {})
class Model(BaseModel):
"""Base class for all data model proxies.
.. note::
All model proxies (based on this class) are generated by an
:class:`environment `
(see the :attr:`odoorpc.ODOO.env` property).
.. doctest::
:options: +SKIP
>>> import odoorpc
>>> odoo = odoorpc.ODOO('localhost', port=8069)
>>> odoo.login('db_name', 'admin', 'password')