The Library client user interface
Our goal here was to learn to write the interface between an external application and the Odoo server, and this was done in the previous section. But it would be a shame not to go the extra step and actually make it available to the end user.
To keep the setup as simple as possible, we will use Python's built-in features to implement the command-line application. Since it is part of the standard library, it does not require any additional installation.
Â
Â
Now, alongside the library_api.py
file, create a new library.py
file. It will first import Python's command-line argument parser and then the LibraryAPI
class, as shown in the following code:
from argparse import ArgumentParser from library_api import LibraryAPI
Next, we describe the commands the argument parser will expect; there are four commands:
- Search and list books
- Add a book
- Set (change) a book title
- Delete a book
This is the code for adding them to the command-line parser:
parser = ArgumentParser() parser...