# ERPPeek ## 资源地址 * 项目地址 https://github.com/tinyerp/erppeek * 文档地址 http://erppeek.readthedocs.io/en/latest/ ## Odoo 客户端工具库 https://github.com/alkivi-sas/python-alkivi-odoo-client https://github.com/katyukha/odoo-rpc-client https://github.com/osiell/odoorpc https://github.com/osiell/oerplib https://pypi.python.org/pypi/odoo_gateway/0.131 ## XML-RPC * Python 例子: ``` import xmlrpclib info = xmlrpclib.ServerProxy('https://demo.odoo.com/start').start() url, db, username, password = \ info['host'], info['database'], info['user'], info['password'] ``` ``` common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url)) common.version() ``` ``` uid = common.authenticate(db, username, password, {}) ``` ``` models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url)) models.execute_kw(db, uid, password, 'res.partner', 'search_read', [[['is_company', '=', True], ['customer', '=', True]]], {'fields': ['name', 'country_id', 'comment'], 'limit': 5}) ``` ## 命令行工具 ```bash erppeek -d demo -m res.users -flogin -fpassword 'login ilike "admin"' ``` ## Shell ``` >>>client.create_database('super_password', 'demo') Logged in as 'admin' >>> client >>> client.db.list() ['demo'] >>> client.user 'admin' >>> client.modules(installed=True) {'installed': ['base', 'web', 'web_mobile', 'web_tests']} >>> len(client.modules()['uninstalled']) 202 >>> # ``` ## 函数库 ``` import erppeek SERVER = 'http://localhost:8069' DATABASE = 'demo' USERNAME = 'admin' PASSWORD = 'admin' client = erppeek.Client(SERVER, DATABASE, USERNAME, PASSWORD) proxy = client.model('res.users') # No need to use the model.search method, the model.browse method accepts a domain users = proxy.browse([]) for user in users: print("{user.id} {user.name}".format(user=user)) ``` ## DEMO