Last active
November 16, 2015 22:14
-
-
Save lvidarte/8ea268b3ed54bacd9060 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
Author
lvidarte
commented
Nov 16, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment