odoo_dev 开发培训作业:图书管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1.1KB

  1. from xmlrpc import client
  2. server_url = 'http://localhost:9999'
  3. db_name = 'library_13'
  4. username = 'user2'
  5. password = '098iop'
  6. common = client.ServerProxy('%s/xmlrpc/2/common' % server_url)
  7. user_id = common.authenticate(db_name, username, password, {})
  8. models = client.ServerProxy('%s/xmlrpc/2/object' % server_url)
  9. if user_id:
  10. # Create book with state draft
  11. book_id = models.execute_kw(db_name, user_id, password, 'library.book', 'create', [{'name': 'New Book',
  12. 'date_release': '2019-01-26',
  13. 'state': 'draft'}])
  14. # Call make_available method on new book
  15. models.execute_kw(db_name, user_id, password, 'library.book', 'make_available', [[book_id]])
  16. # check book status after method call
  17. book_data = models.execute_kw(db_name, user_id, password, 'library.book', 'read', [[book_id], ['name', 'state']])
  18. print(book_data)
  19. print('Book state after method call:', book_data[0]['state'])
  20. else:
  21. print('Wrong credentials')
上海开阖软件有限公司 沪ICP备12045867号-1