Last active
July 17, 2017 03:27
-
-
Save tienhieuD/de244e816956795debadc17cfb85c1b5 to your computer and use it in GitHub Desktop.
For odoo, python 2.7.
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
# -*- coding: utf-8 -*- | |
import xmlrpclib | |
server = "http://localhost:8069" | |
database = "<database-name>" | |
user = "[email protected]" | |
password = "123456" | |
common = xmlrpclib.ServerProxy('%s/xmlrpc/2/common' % server) | |
uid = common.authenticate(database, user, password, {}) | |
OdooApi = xmlrpclib.ServerProxy('%s/xmlrpc/2/object' % server) | |
search_str = OdooApi.execute_kw( | |
database, uid, password, | |
'domain_name.model', # model_name | |
'search_read', # type | |
[[['mahocsinh', '=', '1']]], # conditions | |
{'fields': ['hoten', ], 'limit': 5} # fields gotten & limit count | |
) | |
print (str(search_str)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment