Book Image

Odoo 10 Development Essentials

By : Daniel Reis
Book Image

Odoo 10 Development Essentials

By: Daniel Reis

Overview of this book

Odoo is one of the fastest growing open source, business application development software products available. With announcement of Odoo 10, there are many new features added to Odoo and the face of business applications developed with Odoo has changed. This book will not only teach you how to build and customize business applications with Odoo, but it also covers all the new features that Odoo has to offer. This book is the latest resource on developing and customizing Odoo 10 applications. It comes packed with much more and refined content than its predecessor. It will start with building business applications from scratch and will cover topics such as module extensions, inheritance, working with data, user interfaces, and so on. The book also covers the latest features of Odoo 10, in addition to front end development, testing and debugging techniques. The book will also talk about Odoo Community and Odoo Enterprise.
Table of Contents (20 chapters)
Odoo 10 Development Essentials
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Preface

Developing from your workstation


You may be running Odoo with a Debian/Ubuntu system either in a local virtual machine or in a server over the network. But you may prefer to do the development work at your personal workstation, using your favorite text editor or IDE. This may frequently be the case for developers working from Windows workstations. But it also may be the case for Linux users who need to work on an Odoo server over the local network.

A solution for this is to enable file sharing in the Odoo host so that files are made easy for editing from our workstation. For Odoo server operations, such as a server restart, we can use an SSH shell (such as PuTTY on Windows) alongside our favorite editor.

Using a Linux text editor

Sooner or later, we will need to edit files from the shell command line. In many Debian systems, the default text editor is vi. If you're not comfortable with it, you probably could use a friendlier alternative. In Ubuntu systems, the default text editor is nano. You might prefer it since it's easier to use. In case it's not available in your server, it can be installed with:

$ sudo apt-get install nano

In the following sections, we will assume nano as the preferred editor. If you prefer any other editor, feel free to adapt the commands accordingly.

Installing and configuring Samba

The Samba service helps make Linux file-sharing services compatible with Microsoft Windows systems. We can install it on our Debian/Ubuntu server with this command:

$ sudo apt-get install samba samba-common-bin

The samba package installs the file-sharing services, and the samba-common-bin package is needed for the smbpasswd tool. By default, users allowed to access shared files need to be registered with it. We need to register our user, odoo for example, and set a password for its file share access:

$ sudo smbpasswd -a odoo

After this, we will be asked for a password to use to access the shared directory, and the odoo user will be able to access shared files for its home directory, although it will be read only. We want to have write access, so we need to edit the Samba configuration file to change it as follows:

$ sudo nano /etc/samba/smb.conf

In the configuration file, look for the [homes] section. Edit its configuration lines so that they match the settings as follows:

[homes] 
    comment = Home Directories 
    browseable = yes 
    read only = no 
    create mask = 0640 
    directory mask = 0750 

For the configuration changes to take effect, restart the service:

$ sudo /etc/init.d/smbd restart

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com . If you purchased this book from elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

To access the files from Windows, we can map a network drive for the path \\<my-server-name>\odoo using the specific username and password defined with smbpasswd. When trying to log in with the odoo user, you might encounter trouble with Windows adding the computer's domain to the username (for example, MYPC\odoo). To avoid this, use an empty domain by prepending a \ character to the login (for example, \odoo):

If we now open the mapped drive with Windows Explorer, we will be able to access and edit the contents of the odoo user's home directory:

Odoo includes a couple of tools that are very helpful for developers, and we will make use of them throughout the book. They are technical features and the developer mode. These are disabled by default, so this is a good moment to learn how to enable them.

Activating the developer tools

The developer tools provide advanced server configuration and features. These include a debug menu in the top menu bar along with additional menu options in the Settings menu, in particular the Technical menu.

These tools come disabled by default, and to enable them, we need to log in as admin. In the top menu bar, select the Settings menu. At the bottom-right, below the Odoo version, you will find two options to enable the developer mode; any of them will enable the Debug and Technical menus. The second option, Activate the developer mode (with assets), also disables the minification of JavaScript and CSS used by the web client, making it easier to debug client-side behavior:

After that, the page is reloaded and you should see a bug icon in the top menu bar, just before the session user avatar and name providing the debug mode options. And in the Settings option in the top menu, we should see a new Technical menu section giving access to many Odoo instance internals:

Tip

The Technical menu option allows us to inspect and edit all the Odoo configurations stored in the database, from user interface to security and other system parameters. You will be learning more about many of these throughout the book.