Advertisement
Guest User

Untitled

a guest
Mar 9th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. from django.http import HttpResponse
  2. import xmlrpclib
  3.  
  4. url = "https://demo3.odoo.com"
  5. db = "demo_100_1489044950"
  6. username = "admin"
  7. password = "admin"
  8.  
  9. #odoo service connection
  10. common = xmlrpclib.ServerProxy('{}/xmlrpc/2/common'.format(url))
  11. uid = common.authenticate(db, username, password, {})
  12. models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))
  13. products = models.execute_kw(db, uid, password,
  14. 'product.template', 'search_read',
  15. [[]],
  16. {'fields': ['name', 'list_price'], 'limit': 10})
  17.  
  18. for product in products:
  19. print product['id'], product['name'], product['list_price']
  20.  
  21. def index(request):
  22. html = "<html><body><h1>Odoo Products</h1>"
  23. for product in products:
  24. name = product['name'].encode("utf-8", "strict")
  25. html += "<div>"+name+": "+str(product['list_price'])+"</div>"
  26. html += "</body></html>"
  27. return HttpResponse(html)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement