How to use the odoorpc.error 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_execute_kw.py View on Github external
def test_execute_kw_create_without_args(self):
        # Handle exception (execute a 'create' without args)
        self.assertRaises(
            odoorpc.error.RPCError,
            self.odoo.execute_kw,
            'res.users',
            'create')
github osiell / odoorpc / tests / test_browse.py View on Github external
def test_browse_with_wrong_args(self):
        # Handle exception (execute a 'browse' with wrong args)
        self.assertRaises(
            odoorpc.error.RPCError,
            self.user_obj.browse, "wrong_arg")  # Wrong arg
github osiell / odoorpc / tests / test_execute.py View on Github external
def test_execute_search_with_wrong_args(self):
        # Handle exception (execute a 'search' with wrong args)
        self.assertRaises(
            odoorpc.error.RPCError,
            self.odoo.execute,
            'res.users',
            'search',
            False)  # Wrong arg
github OCA / odoorpc / odoorpc / odoo.py View on Github external
def _check_logged_user(self):
        """Check if a user is logged. Otherwise, an error is raised."""
        if not self._env or not self._password or not self._login:
            raise error.InternalError("Login required")
github osiell / odoorpc / odoorpc / service / inspect / dependencies.py View on Github external
def make_dot(self):
        """Returns a `pydot.Dot` object representing dependencies
        between modules.

            >>> graph = oerp.inspect.dependencies(['base'], ['res.partner'])
            >>> graph.make_dot()
            

        See the `pydot `_ documentation
        for details.
        """
        try:
            import pydot
        except ImportError:
            raise error.InternalError("'pydot' module not found")
        output = pydot.Dot()

        def get_template(module, data):
            """Generate the layout of the module."""
            root = all(not self._modules[depend]['keep']
                       for depend in data['depends'])
            # Model lines
            tpl_models = []
            for model in sorted(data['models']):
                color_model = self._config['model_color_normal']
                if self._models[model]['transient']:
                    color_model = self._config['model_color_transient']
                tpl_models.append(
                    TPL_MODULE_MODEL.format(
                        color_model=color_model, model=model))
            # Module comment
github OCA / odoorpc / odoorpc / models.py View on Github external
def __isub__(self, records):
        if not self._from_record:
            raise error.InternalError("No parent record to update")
        try:
            list(records)
        except TypeError:
            records = [records]
        parent = self._from_record[0]
        field = self._from_record[1]
        updated_values = parent._values_to_write[field.name]
        values = []
        if updated_values.get(parent.id):
            values = updated_values[parent.id][:]  # Copy
        from odoorpc import fields

        for id_ in fields.records2ids(records):
            if (4, id_) in values:
                values.remove((4, id_))
            if (3, id_) not in values:
github osiell / odoorpc / odoorpc / odoo.py View on Github external
except ValueError:
            raise ValueError("The timeout must be a float")
        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})
github OCA / odoorpc / odoorpc / service / common.py View on Github external
def rpc_method(*args):
            """Return the result of the RPC request."""
            try:
                meth = getattr(self._odoo._connector.common, method, False)
                return meth(*args)
            except rpc.error.ConnectorError as exc:
                raise error.RPCError(exc.message, exc.odoo_traceback)
        return rpc_method