Book Image

Odoo Development Essentials

Book Image

Odoo Development Essentials

Overview of this book

Table of Contents (17 chapters)
Odoo Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Writing a Notes desktop application


Let's do something interesting with the RPC API. What if users could manage their Odoo to-do tasks directly from their computer's desktop? Let's write a simple Python application to do just that, as shown in the following screenshot:

For clarity, we will split it into two files: one concerned to interact with the server backend, note_api.py, and another with the graphical user interface, note_gui.py.

Communication layer with Odoo

We will create a class to set up the connection and store its information. It should expose two methods: get() to retrieve task data and set() to create or update tasks.

Select a directory to host the application files and create the note_api.py file. We can start by adding the class constructor, as follows:

import xmlrpclib
class NoteAPI():
    def __init__(self, srv, db, user, pwd):
        common = xmlrpclib.ServerProxy(
            '%s/xmlrpc/2/common' % srv)
        self.api = xmlrpclib.ServerProxy(
            '%s/xmlrpc/2/object...