Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Last active November 16, 2015 22:14
Show Gist options
  • Save lvidarte/8ea268b3ed54bacd9060 to your computer and use it in GitHub Desktop.
Save lvidarte/8ea268b3ed54bacd9060 to your computer and use it in GitHub Desktop.
import xmlrpclib
url = 'http://odoo.staging.coquelux.com.br:8069'
username = 'leonardo.vidarte@**********.com'
password = '*********'
db = 'erp_odoo'
common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})
if uid:
obj = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))
ids = obj.execute_kw(db, uid, password,
'product.template', 'search',
[[['list_price', '>', '0']]])
if ids:
products = obj.execute_kw(db, uid, password,
'product.template', 'read',
[ids], {'fields': ['name', 'list_price']})
for p in products:
print('id: {}, name: {}, price: {}'.format(
p['id'], p['name'].encode('utf-8'), p['list_price']))
else:
print('no login')
@lvidarte
Copy link
Author

$> python odoo.py 
id: 2, name: Camisa leñadora, price: 5.0
id: 1, name: Jean clásico, price: 1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment