def _build_odoo_env(self, odoo_args):
odoo.tools.config.parse_config(odoo_args)
dbname = odoo.tools.config['db_name']
odoo.tools.config['workers'] = 0
odoo.tools.config['xmlrpc'] = False
if not dbname:
argparse.ArgumentParser().error(
"please provide a database name though Odoo options (either "
"-d or an Odoo configuration file)"
)
logging.getLogger(odoo_logger).setLevel(logging.ERROR)
odoo.service.server.start(preload=[], stop=True)
# odoo.service.server.start() modifies the SIGINT signal by its own
# one which in fact prevents us to stop anthem with Ctrl-c.
# Restore the default one.
signal.signal(signal.SIGINT, signal.default_int_handler)
registry = odoo.modules.registry.RegistryManager.get(dbname)
cr = registry.cursor()
uid = odoo.SUPERUSER_ID
Environment.reset()
context = Environment(cr, uid, {})['res.users'].context_get()
return Environment(cr, uid, context)
评论列表
文章目录