Book Image

Odoo 12 Development Essentials - Fourth Edition

By : Daniel Reis
Book Image

Odoo 12 Development Essentials - Fourth Edition

By: Daniel Reis

Overview of this book

Odoo is one of the best platforms for open source ERP and CRM. Its latest version, Odoo 12, brings with it new features and updates in Python packages to develop more customizable applications with additional cloud capabilities. The book begins by covering the development essentials for building business applications. You will start your journey by learning how to install and configure Odoo, and then transition from having no specific knowledge of Odoo to being ready for application development. You will develop your first Odoo application and understand topics such as models and views. Odoo 12 Development Essentials will also guide you in using server APIs to add business logic, helping you lay a solid foundation for advanced topics. As you progress through the chapters, you will be equipped to build and customize your applications and explore the new features in Odoo 12, such as cloud integration, to scale your business applications. You will get insights into building business logic and integrating various APIs into your application. By the end of the book, you will be able to build a business application from scratch by using the latest version of Odoo.
Table of Contents (22 chapters)
Title Page
Packt Upsell
Foreword
Contributors
Preface
Index

Running server methods using XML-RPC


With XML-RPC, no session is maintained and the authentication credentials are sent with every request. This adds some overhead to the protocol, but makes it simpler to use.

 

 

Next, we set up access to the server methods that need a login to be accessed. These are exposed at the /xmlrpc/2/object endpoint, as shown in the following:

>>> api = client.ServerProxy('%s/xmlrpc/2/object' % srv)
>>> api.execute_kw(db, uid, pwd, 'res.partner', 'search_count', [[]])
42

Here, we are accessing the server API for the first time, performing a count on the Partner records. Methods are called using the execute_kw() method that takes the following arguments:

  • The name of the database to connect to
  • The connection user ID
  • The user password
  • The target model identifier name
  • The method to call
  • A list of positional arguments
  • An optional dictionary with keyword arguments (not used in the example)

The preceding example calls the search_count method of the res.partner model...