浏览odoo/openerp data的通用工具
Odool的Python项目详细描述
下载并安装最新版本:
pip install -U odooly
文档和教程:http://odooly.readthedocs.org
ci测试:https://travis-ci.org/tinyerp/odooly
Overview
奥多利有三个完整的用途:
- 使用命令行参数
- 作为交互式外壳
- 作为客户库
主要功能:
- 通过json-rpc和xml-rpc提供一个非常接近odoo api 8.0的api
- 与OpenERP 6.1至ODOO 12.0兼容
- 单个可执行文件odooly.py,无外部依赖关系
- 用于search、数据模型内省等的帮助程序。
- 搜索domain和fields 的简化语法
- 可在Client.env环境中访问的完整api
- 模块可以导入并用作库:from odooly import Client
- 支持Python3.4及更高版本,以及Python2.7
Command line arguments
从命令行查询odoo模型的参数很少。 虽然它非常有限:
$ odooly --help Usage: odooly.py [options] [search_term_or_id [search_term_or_id ...]] Inspect data on Odoo objects. Use interactively or query a model (-m) and pass search terms or ids as positional parameters after the options. Options: --version show program's version number and exit -h, --help show this help message and exit -l, --list list sections of the configuration --env=ENV read connection settings from the given section -c CONFIG, --config=CONFIG specify alternate config file (default: 'odooly.ini') --server=SERVER full URL of the server (default: http://localhost:8069/xmlrpc) -d DB, --db=DB database -u USER, --user=USER username -p PASSWORD, --password=PASSWORD password, or it will be requested on login -m MODEL, --model=MODEL the type of object to find -f FIELDS, --fields=FIELDS restrict the output to certain fields (multiple allowed) -i, --interact use interactively; default when no model is queried -v, --verbose verbose $ #
示例:
$ odooly -d demo -m res.partner -f name -f lang 1 "name","lang" "Your Company","en_US"
$ odooly -d demo -m res.groups -f full_name 'id > 0' "full_name" "Administration / Access Rights" "Administration / Configuration" "Human Resources / Employee" "Usability / Multi Companies" "Usability / Extended View" "Usability / Technical Features" "Sales Management / User" "Sales Management / Manager" "Partner Manager"
Interactive use
编辑odooly.ini并声明环境:
[DEFAULT] scheme = http host = localhost port = 8069 database = odoo username = admin [demo] username = demo password = demo protocol = xmlrpc [demo_jsonrpc] username = demo password = demo protocol = jsonrpc [local] scheme = local options = -c /path/to/odoo-server.conf --without-demo all
连接到ODOO服务器:
odooly --list odooly --env demo
这是一个示例会话:
>>> env['res.users'] <Model 'res.users'> >>> env['res.users'].search_count() 4 >>> crons = env['ir.cron'].with_context(active_test=False).search([]) >>> crons.read('active name') [{'active': True, 'id': 5, 'name': 'Calendar: Event Reminder'}, {'active': False, 'id': 4, 'name': 'Mail: Fetchmail Service'}] >>> # >>> env.modules('delivery') {'uninstalled': ['delivery', 'website_sale_delivery']} >>> env.upgrade('base') 1 module(s) selected 42 module(s) to process: to upgrade account to upgrade account_chart to upgrade account_tax_include to upgrade base ... >>> #
注意
使用--verbose开关查看场景背后发生了什么。 行被截短为79个字符。使用-vv或-vvv打印 更多。
注意
要在关闭会话时保留命令的历史记录,请首先 在主目录中创建空文件: touch ~/.odooly_history