How to use the odoorpc.error.RPCError 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 osiell / odoorpc / tests / test_db_drop.py View on Github external
def test_db_drop_no_existing_database(self):
        if v(self.odoo.version) >= v('6.1'):
            res = self.odoo.db.drop(ARGS.super_admin_passwd, 'fake_db_name')
            self.assertFalse(res)
        else:
            self.assertRaises(
                odoorpc.error.RPCError,
                self.odoo.db.drop,
                ARGS.super_admin_passwd, 'fake_db_name')
github OCA / odoorpc / tests / test_db_drop.py View on Github external
def test_db_drop_no_existing_database(self):
        if v(self.odoo.version) >= v('6.1'):
            res = self.odoo.db.drop(ARGS.super_admin_passwd, 'fake_db_name')
            self.assertFalse(res)
        else:
            self.assertRaises(
                odoorpc.error.RPCError,
                self.odoo.db.drop,
                ARGS.super_admin_passwd, 'fake_db_name')
github osiell / odoorpc / tests / test_browse.py View on Github external
def test_browse_with_wrong_id(self):
        # Handle exception (execute a 'browse' with wrong ID)
        self.assertRaises(
            odoorpc.error.RPCError,
            self.user_obj.browse, 999999999)
github OCA / odoorpc / odoorpc / odoo.py View on Github external
:return: a dictionary (JSON response)
        :raise: :class:`odoorpc.error.RPCError`
        :raise: `urllib2.HTTPError` (if `params` is not a dictionary)
        :raise: `urllib2.URLError` (connection error)

        *Python 3:*

        :return: a dictionary (JSON response)
        :raise: :class:`odoorpc.error.RPCError`
        :raise: `urllib.error.HTTPError` (if `params` is not a dictionary)
        :raise: `urllib.error.URLError` (connection error)
        """
        data = self._connector.proxy_json(url, params)
        if data.get('error'):
            raise error.RPCError(
                data['error']['data']['message'], data['error']
            )
        return data
github osiell / odoorpc / odoorpc / service / wizard.py View on Github external
def rpc_method(*args):
            """Return the result of the RPC request."""
            try:
                meth = getattr(self._oerp._connector.wizard, method, False)
                return meth(self._oerp.database, self._oerp.user.id, *args)
            except rpc.error.ConnectorError as exc:
                raise error.RPCError(exc.message, exc.oerp_traceback)
        return rpc_method
github osiell / odoorpc / odoorpc / odoo.py View on Github external
:return: a dictionary (JSON response)
        :raise: :class:`odoorpc.error.RPCError`
        :raise: `urllib2.HTTPError` (if `params` is not a dictionary)
        :raise: `urllib2.URLError` (connection error)

        *Python 3:*

        :return: a dictionary (JSON response)
        :raise: :class:`odoorpc.error.RPCError`
        :raise: `urllib.error.HTTPError` (if `params` is not a dictionary)
        :raise: `urllib.error.URLError` (connection error)
        """
        data = self._connector.proxy_json(url, params)
        if data.get('error'):
            raise error.RPCError(
                data['error']['data']['message'],
                data['error'])
        return data
github OCA / odoorpc / odoorpc / service / wizard.py View on Github external
def rpc_method(*args):
            """Return the result of the RPC request."""
            try:
                meth = getattr(self._oerp._connector.wizard, method, False)
                return meth(self._oerp.database, self._oerp.user.id, *args)
            except rpc.error.ConnectorError as exc:
                raise error.RPCError(exc.message, exc.oerp_traceback)
        return rpc_method