Guide to Backend + Odoo

The following guide refers mainly to the @acabrera post. It is far away from being complete. Feel free to comment/correct it:

Linux part

  • apt-get update
  • apt-get upgrade
  • sudo apt install postgresql -y
  • wget -O - https://nightly.odoo.com/odoo.key | sudo gpg --dearmor -o /usr/share/keyrings/odoo-archive-keyring.gpg
  • echo ‘deb [signed-by=/usr/share/keyrings/odoo-archive-keyring.gpg] Index of /16.0/nightly/deb/ ./’ | sudo tee /etc/apt/sources.list.d/odoo.list
  • apt-get update
  • apt-get install odoo
  • nano /etc/postgresql/13/main/postgresql.conf
...
      listen_addresses = '*'
...
  • nano /etc/postgresql/13/main/pg_hba.conf
# IPv4 local connections:
host    all             all             0.0.0.0/0               md5
  • service postgresql restart
  • Login to your Odoo-Installation on Port 8069 and follow the assistent. Be sure to use lower case letter for database name.
    From the Apps screen, go ahead and Activate an app such as the CRM app. For some reason, this is necessary in order to have additional options enabled that we will need later. Once you refresh the page, you should now see that there are more options but we’ll come back to this in a bit.
  • Once the page refreshes, you should now see that there are more options:
    ** Click the icon at the top left of the screen and then select Settings
    ** Scroll all the way down and click on “Activate the developer mode” / “Entwicklermodus aktivieren”
  • go back to the console:
  • service odoo restart
  • cd /etc/odoo/
  • mkdir custom_addons
  • cd /etc/odoo/custom_addons/
  • mkdir Development
  • cd Development/
  • git clone GitHub - OpenEMS/odoo-openems: Odoo Addons for OpenEMS
  • cd odoo-openems/
  • sudo cp -r openems/ /etc/odoo/custom_addons/
  • sudo nano /etc/odoo/odoo.conf
    and add
addons_path = /etc/odoo/custom_addons

cd …
git clone GitHub - OCA/partner-contact: Odoo Partner and Contact related addons
cd partner-contact/
cp -r partner_firstname/ /etc/odoo/custom_addons/
cd …
git clone GitHub - OCA/web: Odoo web client UI related addons
cd web/
cp -r web_m2x_options/ /etc/odoo/custom_addons/

  • Go back to Odoo in the browser and refresh the page.
    ** Click the icon at the top left, again, and select Apps
    ** Click “Update Apps List” at the top of the page. This will restart Odoo.

  • In the App search box, type in and Activate the following modules, after ‘’‘clearing any filters’‘’, in this order:
    ** partner_firstname
    ** web_m2x_options
    ** openems

  • Create a new use in Odoo for backend usage. Be sure to set right for OpenEMS usage - at least Read access. Attention: User rights are NOT on the OpenEMS-ribbon! Save setting via the cloud-symbol on the upper left corner.

  • Now you go to the OpenEMS-App. Go to “Administration” in the upper middle line and create a new setup protocol. There you can choose a Device. It is adviced to use names with letters and a trailing number, such as edge0. The trailing number will be used to generate a database entry!
    The API-Key you set there will later be used to connect the edge device to backend.
    ** Upper left corner → Settings → Users and Groups (upper middle)

  • Go back to Odoo-page in your browser. New devices have to be setup via a new setup protocol.

  • If there are no errors you´ll find the created ‘‘edge0’’ in device list from Odoo´s OpenEMS-App.

  • In User settings you can connect an openEMS device to a created user.

  • Go to your visual studio code instance and build backend UI

ng build -c "openems,openems-backend-prod,prod"

  • Copy ui/target directory to your webserver instance to /opt/openems-backend
  • Create service descriptions as described in the [Deploy OpenEMS Backend :: Open Energy Management System Getting Started Guide]
  • Create config file for apache2:
  • nano /etc/apache2/sites-available/openems-backend.conf
     <VirtualHost *:81>
      #-BASIC-CONFIGURATION
         ServerName localhost
         ServerAdmin MyAdmin@admin.com
         DocumentRoot "/usr/share/openems-backend/www"

      #-SERVER-CONFIGURATION
        RewriteEngine On

        ProxyPass /openems-backend-ui    ws://127.0.0.1:8082/
        ProxyPassReverse /openems-backend-ui    ws://127.0.0.1:8082/


#      #-DIRECTORY-CONFIGURATION
         <Directory "/usr/share/openems-backend/www">
            RewriteBase /
            RewriteRule ^index\.html$ - [L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.html [L]
            Options Indexes FollowSymLinks
            AllowOverride None
            Require all granted
         </Directory>
#
      #-LOGGING
#         CustomLog "|/progs/apache_instance/bin/rotatelogs logs/my-log_log.%Y.%m.%d 86400" common
ErrorLog "/var/log/apache2/openems-backend/error.log"
CustomLog "/var/log/apache2/openems-backend/access.log" common
    </VirtualHost>
  • Create symlink to sites-enabled and restart apache2:
ln -s /etc/apache2/sites-available/openems-backend.conf /etc/apache2/sites-enabled/openems-backend.conf

service apache2 restart

Maybe you have to install some additional apache-modules for the rewrite engine.
The rest of the configuration is described in the Getting Started Guide

4 Likes