There's more...

Like XML-RPC, you can use the check_access_rights method in JSON-RPC to check whether you have access rights to perform the operation. This method requires two parameters—model name and the operation name. In the following example, we check access rights for the create operation on the library.book model:

# place authentication and get_json_payload method (see last recipe for more)
if user_id:
payload = get_json_payload("object", "execute_kw",
db_name, user_id, password,
'library.book', 'check_access_rights', ['create'])
res = requests.post(json_endpoint, data=payload, headers=headers).json()
print("Has create access:", res['result'])

else:
print("Failed: wrong credentials")

This program will give the following output:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset