Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*Python 2:*
:raise: :class:`odoorpc.error.RPCError`
(access denied / database already exists)
:raise: :class:`odoorpc.error.InternalError` (dump file closed)
:raise: `urllib2.URLError` (connection error)
*Python 3:*
:raise: :class:`odoorpc.error.RPCError`
(access denied / database already exists)
:raise: :class:`odoorpc.error.InternalError` (dump file closed)
:raise: `urllib.error.URLError` (connection error)
"""
if dump.closed:
raise error.InternalError("Dump file closed")
b64_data = base64.standard_b64encode(dump.read()).decode()
self._odoo.json(
'/jsonrpc',
{'service': 'db',
'method': 'restore',
'args': [password, db, b64_data, copy]})
def __iadd__(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 (3, id_) in values:
values.remove((3, id_))
if (4, id_) not in values:
values.append((4, id_))
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")
def make_dot(self):
"""Returns a `pydot.Dot` object representing relations between models.
>>> graph = oerp.inspect.relations(['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(
graph_type='digraph', overlap='scalexy', splines='true',
nodesep=str(self._config['space_between_models']))
for model, data in self._relations.iteritems():
# Generate attributes of the model
attrs_ok = False
attrs = []
if self._attrs_whitelist \
and match_in(model, self._attrs_whitelist):
attrs_ok = True
if self._attrs_blacklist \
and match_in(model, self._attrs_blacklist):
attrs_ok = False
if attrs_ok:
subtitle = TPL_MODEL_SUBTITLE.format(
color=self._config['model_color_subtitle'],
def _check_root_modules(self):
"""Check if `root` modules exist, raise an error if not."""
module_obj = self.oerp.get('ir.module.module')
for module in self._root_modules:
if not module_obj.search([('name', 'ilike', module)]):
raise error.InternalError(
"'{0}' module does not exist".format(module))
def __iadd__(self, records):
if not self.parent or not self.parent_field:
raise error.InternalError("No parent record to update")
try:
list(records)
except TypeError:
records = [records]
updated_values = self.parent.__data__['updated_values']
res = []
if updated_values.get(self.parent_field.name):
res = updated_values[self.parent_field.name][:] # Copy
from odoorpc.service.model import fields
for id_ in fields.records2ids(records):
if (3, id_) in res:
res.remove((3, id_))
if (4, id_) not in res:
res.append((4, id_))
return res