Skip to main content

Server and module updates

Server and module updates

Once the Odoo server is up-and-running, you'll need to install updates on Odoo. This involves two steps—getting new versions of the source code (for the server or modules) and installing them.

Creating a staging environment

If you have followed the approach described in the Installing from the source code section correctly, you should now be able to fetch and test new versions of source code in the staging repository. It's strongly advised that you make a copy of the production database and test any upgrades on it. If odoo-prod is your production database, an odoo-stage copy can be created with the following commands:
$ dropdb odoo-stage
$ createdb --owner=odoo odoo-stage
$ pg_dump odoo-prod | psql -d odoo-stage
$ sudo su odoo
$ cd ~/.local/share/Odoo/filestore/
$ cp -al odoo-prod odoo-stage  # create filestore hardlinks
$ exit
Before we can use the preceding copy of the database, cleanup should be done, such as deactivating scheduled actions, and email servers (both for sending and fetching messages). The specific steps needed here depend on your setup, but it's likely they can be automated by a script. Remember that the psql command can be used to run SQL directly from the command line, such as psql -d odoo-stage -c "<SQL command>".

Note

A database copy can be made in a much faster way using the createdb command,  $ createdb --owner=odoo --template=odoo-prod odoo-stage. The caveat here is that, for it to run, there can't be any open connections to the odoo-prod database, so the Odoo production server needs to be stopped.

Updating Odoo source code

To get the latest Odoo source code from the GitHub repository, we use the git pull command. Before doing that, we can use the git tag command to create a tag for the current commit in use, so that it's easier to revert the code update, as follows:
$ sudo su odoo
$ cd ~/odoo-12
$ git tag --force 12-last-prod
$ git pull
For code changes to take effect, we need to restart the Odoo service. For data file changes to take effect, an upgrade to the modules is needed. As a general rule, changes to Odoo stable versions are considered code fixes, and it's therefore not often worth the risk of performing module upgrades. If you need to perform a module upgrade, however, it can be achieved using the -u <module> additional option, or -u base, which upgrades all modules.
Now it's time to start the Odoo staging server, which will use the update code on it staging database, as follows:
$ ~/odoo-12/odoo-bin -d odoo-stage --http-port=8080 \
-c /etc/odoo/odoo.conf  # optionally add: -u base
$ exit
This Odoo staging server was configured to listen on the 8080 port. We can navigate there with our web browser, using an address such as  http://localhost:8080, to check whether the upgraded code works correctly.
If something goes wrong, we can revert the code to an earlier version with the following code:
$ sudo su odoo
$ cd ~/odoo-12
$ git checkout 12-last-prod
$ exit


If everything works as expected, it should be safe to perform an upgrade on the production service, which is usually done by restarting it. If you want to perform an actual module upgrade, the suggested approach is to stop the server, run the upgrade, and then restart the service, as follows:
$ sudo service odoo stop
$ sudo su -c "~/odoo-12/odoo-bin -c /etc/odoo/odoo.conf" \
" -u base --stop-after-init" odoo
$ sudo service odoo start
Remember to make a note of the Git reference in use by checking out the necessary version. This will enable you to rollback any changes if necessary. Keeping a backup of the database before an upgrade is also highly advised.
After this is complete, we can pull the new versions to the production repository using Git and complete the upgrade as follows:
$ sudo su odoo
$ cd ~/odoo-12
$ git tag --force 12-last-prod
$ git pull
$ exit
$ sudo service odoo restart # or: sudo systemctl restart odoo
There's no point in updating too frequently, but it's not advised that you wait a year between updates either. Performing an update every few months is usually fine. Also note that a server restart should be enough to enable code updates—and that module upgrades aren't always necessary.
If you need a specific bug fix, however, an earlier update should be considered. Remember to also watch out for security bug disclosures on public channels such as GitHub Issues for Odoo, in particular, ones displaying the Securitytag, at https://github.com/odoo/odoo/issues?q=is%3Aissue+label%3ASecurity, or the Odoo official mailing lists, which can be subscribed to at https://www.odoo.com/groups.
As part of the service, enterprise contract customers can expect early email notifications alerting them to this type of issue.

Comments

Popular posts from this blog

The message and activity features

The message and activity features Odoo has available global  messaging  and activity planning features, provided by the  Discuss  application, with technical name mail. The mail module provides the  mail.thread  abstract class that makes it simple to add the messaging features to any model, and the  mail.activity.mixin  that adds planned activity features. This was done in  Chapter 4 ,  Extending Modules , to explain how to inherit features from mixin abstract classes. To add these features, we need to add the mail dependency to the add-on module,  library_checkout , and then have the library checkout model class inherit from the abstract classes providing the following features. Edit the  'depends'  key in the  library_checkout/__manifest__.py   file, to add the mail module, shown as follows: Copy 'depends': ['library_member' , 'mail' ], And edit the  library_checkout/m...

Setting up an nginx reverse proxy

Setting up an nginx reverse proxy While Odoo itself can serve web pages, it's strongly recommended that there is a  reverse  proxy positioned in front of it. A reverse proxy acts as an intermediary that manages the traffic between clients sending requests and the Odoo servers responding to them. Using a reverse proxy has several benefits. On the security side, it can do the following: Handle (and enforce) HTTPS protocols to encrypt traffic Hide the internal network characteristics Act as an application firewall, limiting the URLs accepted for processing Also, on the performance side, it can provide the following significant improvements: Cached static content, hence reducing the load on the Odoo servers Compressed content to speed up loading time Act as a load balancer, distributing load between several servers Apache is a popular choice when considering a reverse proxy, although  nginx  is a recent alternative with good technical argumen...

The QWeb template language

The QWeb template language The  QWeb  parser looks for special directives in the templates and replaces them with dynamically generated HTML. These directives are XML element attributes and can be used in any valid tag or element, such as  <div> ,  <span> , or  <field> . Sometimes, we may want to use a QWeb directive but we don't want to place it in any of the XML elements in our template. For those cases, we have a  <t>  special element that can have QWeb directives, such as  t-if  or  t-foreach , but is silent and won't have any output on the final XML/HTML produced. The QWeb directives will frequently make use of evaluated expressions to produce different results, depending on the current record values. There are two different QWeb implementations: client-side JavaScript and server-side Python. The reports and website pages use the server-side Python implementation of QWeb. Kanban views us...