How to use the odoorpc.tools function in OdooRPC

To help you get started, we’ve selected a few OdooRPC examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OCA / odoorpc / tests / test_tools.py View on Github external
def test_v_cmp(self):
        # [(v1, v2, is_inferior), ...]
        versions = [
            ('7.0', '6.1', False), ('6.1', '7.0', True),
            ('7.0alpha', '6.1', False), ('6.1beta', '7.0', True),
            ('6.1beta', '5.0.16', False), ('5.0.16alpha', '6.1', True),
            ('8.0dev-20131102-000101', '7.0-20131014-231047', False),
        ]
        for v1, v2, is_inferior in versions:
            result = tools.v(v1) < tools.v(v2)
            if is_inferior:
                self.assertTrue(result)
            else:
                self.assertFalse(result)
github osiell / odoorpc / tests / test_tools.py View on Github external
def test_v_cmp(self):
        # [(v1, v2, is_inferior), ...]
        versions = [
            ('7.0', '6.1', False), ('6.1', '7.0', True),
            ('7.0alpha', '6.1', False), ('6.1beta', '7.0', True),
            ('6.1beta', '5.0.16', False), ('5.0.16alpha', '6.1', True),
            ('8.0dev-20131102-000101', '7.0-20131014-231047', False),
        ]
        for v1, v2, is_inferior in versions:
            result = tools.v(v1) < tools.v(v2)
            if is_inferior:
                self.assertTrue(result)
            else:
                self.assertFalse(result)
github osiell / odoorpc / tests / test_tools.py View on Github external
def test_clean_version_numeric(self):
        version = tools.clean_version('6.1')
        self.assertEqual(version, '6.1')
github osiell / odoorpc / tests / test_session.py View on Github external
def test_session_tools_get(self):
        self.odoo.save(self.session_name, rc_file=self.file_path)
        data = {
            'type': self.odoo.__class__.__name__,
            'server': self.odoo.server,
            'protocol': self.odoo.protocol,
            'port': int(self.odoo.port),
            'timeout': self.odoo.config['timeout'],
            'user': self.odoo.user.login,
            'passwd': self.odoo._password,
            'database': self.odoo.db,
        }
        result = odoorpc.tools.session.get(
            self.session_name, rc_file=self.file_path)
        self.assertEqual(data, result)
        odoorpc.ODOO.remove(self.session_name, rc_file=self.file_path)
github OCA / odoorpc / tests / test_tools.py View on Github external
def test_clean_version_numeric(self):
        version = tools.clean_version('6.1')
        self.assertEqual(version, '6.1')
github OCA / odoorpc / tests / test_session.py View on Github external
def test_session_tools_get_all(self):
        self.odoo.save(self.session_name, rc_file=self.file_path)
        data = {
            self.session_name: {
                'type': self.odoo.__class__.__name__,
                'server': self.odoo.server,
                'protocol': self.odoo.protocol,
                'port': int(self.odoo.port),
                'timeout': self.odoo.config['timeout'],
                'user': self.odoo.user.login,
                'passwd': self.odoo._password,
                'database': self.odoo.db,
            }
        }
        result = odoorpc.tools.session.get_all(rc_file=self.file_path)
        self.assertIn(self.session_name, result)
        self.assertEqual(data, result)
        odoorpc.ODOO.remove(self.session_name, rc_file=self.file_path)
github OCA / odoorpc / odoorpc / odoo.py View on Github external
"""Execute the workflow `signal` on
        the instance having the ID `record_id` of `model`.

        *Python 2:*

        :raise: :class:`odoorpc.error.RPCError`
        :raise: :class:`odoorpc.error.InternalError` (if not logged)
        :raise: `urllib2.URLError` (connection error)

        *Python 3:*

        :raise: :class:`odoorpc.error.RPCError`
        :raise: :class:`odoorpc.error.InternalError` (if not logged)
        :raise: `urllib.error.URLError` (connection error)
        """
        if tools.v(self.version)[0] >= 11:
            raise DeprecationWarning(
                u"Workflows have been removed in Odoo >= 11.0"
            )
        self._check_logged_user()
        # Execute the workflow query
        args_to_send = [
            self.env.db,
            self.env.uid,
            self._password,
            model,
            signal,
            record_id,
        ]
        data = self.json(
            '/jsonrpc',
            {
github OCA / odoorpc / odoorpc / odoo.py View on Github external
self._port = port
        self._protocol = protocol
        self._env = None
        self._login = None
        self._password = None
        self._db = DB(self)
        self._report = Report(self)
        # Instanciate the server connector
        try:
            self._connector = rpc.PROTOCOLS[protocol](
                self._host, self._port, timeout, version, opener=opener
            )
        except rpc.error.ConnectorError as exc:
            raise error.InternalError(exc.message)
        # Dictionary of configuration options
        self._config = tools.Config(
            self,
            {'auto_commit': True, 'auto_context': True, 'timeout': timeout},
        )
github osiell / odoorpc / odoorpc / odoo.py View on Github external
self._host = host
        self._port = port
        self._protocol = protocol
        self._env = None
        self._login = None
        self._password = None
        self._db = DB(self)
        self._report = Report(self)
        # Instanciate the server connector
        try:
            self._connector = rpc.PROTOCOLS[protocol](
                self._host, self._port, timeout, version)
        except rpc.error.ConnectorError as exc:
            raise error.InternalError(exc.message)
        # Dictionary of configuration options
        self._config = tools.Config(
            self,
            {'auto_commit': True,
             'auto_context': True,
             'timeout': timeout})