Upgrading to Flectra 2 - A Journal

A tale of woe and hope

Let's upgrade Flectra

Upgrade to Flectra 2 - A Journal

A few years ago, just before Covid, we were looking for an e-commerce engine to start our online shop that was spun out of our main business. We were also looking for an accounting system to replace the Windows-based system that our succession of bookkeepers insisted on using. When our last bookkeeper emigrated we felt it was an opportune time to bring it all in-house and rely on an open-source system where we could take it places we never considered before with a closed-sourced system and, at the same time, begin to offer support and subscriptions from the creators to our customers who would find the product as useful as we did.

We looked at open-source accounting systems about a decade ago, sans the e-commerce requirement. At the time the main contenders were OpenBravo, Tiny ERP and SQLedger. We didn't settle on any of them at the time. Our risk assessment was as follows:

  • OpenBravo - too complex, the project did not have a track record yet so it's future was uncertain. The community was still nascent.
  • SQLedger - Written in Perl, looked like development had stalled and was butt ugly but could meet our limited accounting requirements at the time.
  • Tiny ERP - too complex for our requirements at the time and was client based.

None of these projects would have turned out to be a good option to bet the company accounting system on. OpenBravo, stopped its open-source editions in 2019. Seems they regret the use of Open in their name now. Tiny ERP became Odoo and, as I will expand on,  is being closed off section by section and SQLedger went nowhere.

When it came time to look at this again Tiny ERP, now Odoo, stood out as a great option feature and customisation wise and it was now web-based but its business model left no doubt that the community edition is on notice. While looking we came across Flectra, a fork of Odoo, and it at least seemed to address some of the risks with Odoo. There was a lot of bad stuff being said online but since we were new to the Odoo/Flectra world it was hard to tell who was "in the right". Suffice it to say no one looked clean but I could understand the fork given Odoo's moves to reduce functionality.  We wouldn't want to sign up for a project that looked hostile to its community user base.

The lack of a vibrant community around Flectra and that it was a new, unproven project was a big risk for us but we were under pressure and accepting the risk implemented Flectra.

Shortly after implementing Flectra 1.6 and then upgrading to 1.7 Flectra 2 was announced. This was not great news for us major version upgrade option from Flectra and Odoot is something we knew was going to happen sooner or later.  Unlike Odoo where it is relatively easy to find assistance in the community with Flectra, this is less so. Flectra's main communication channel is Telegram which is a walled garden that cannot be queried nor searched with a browser. Questions need to be answered time and again as there is no history for users to refer to.  It's hard to build up a knowledge repository this was which is supposed to be one of the benefits of open-source for adopters.

This journal is our contribution to the Flectra community and to FlectraHQ to see if we can help build up the expertise and knowledge that a vibrant open-source community can provide and to thank the Flectra developers for their efforts. I am not sure where this journey will end but I am hopeful that with the community expertise, we can assist each other and Flectra with this important project.to get all things sorted. To make sure its clear we have not yet completed the upgrade process but want to document what we have tried so far in the hope it helps others and we can work out the steps required for a successful upgrade as a community.

Base Server Setup

We set up a virtual machine to test the upgrade process. This would allow us to snapshot and roll back as needed as we experimented with the upgrade. We are using a Ubuntu 20.04 virtual machine as its version of Python and Postgres have fewer issues with Odoo 12,13 and 14 than Ubuntu 22.04. to get all things sorted.to get all things sorted.to get all things sorted.to get all things sorted.to get all things sorted. Our production server is using Ubuntu 18.04 just in case this becomes relevant later.

The plan is, based on fragmented information online, to upgrade from Flectra 1.7 to Odoo 12, then 13 and 14 before installing Felctra 2. The major version upgrades will be done with the Odoo community tool OpenUpgrade. There was a change in the way OpenUpgrade works from 13 to 14 which we will document, but the high-level steps for each version upgrade are as follows:

  • Install Odoo.x from deb packages
  • Install OpenUpgrade migration scripts for the relevant version (e.g branch 12.0 for Flectra 1.7 to Odoo 12)
  • Copy over and install the relevant data, and files to be upgraded
  • Update our custom modules
  • Install our standard modules for the Odoo.x version
  • Run the OpenUpgrade process
  • Run the Odoo.x update
  • Start the Odoo.x process and see if it works
  • Repeat till we at the right version for flectra2
  • Update to Flectra2
  • Profit!!!

Sounds like a walk-in-the-park right? Sadly far things don't look good. Here is what we have achieved so far.

Getting ready to go

 

Postgresql Setup

  • Install  Postgres
    • sudo apt install postgresql
  • Downloaded the database backup file and restore to the VM. In Postgres CLI:
    • "create role flectra with login encrypted password 'flectra';"
    • "create database finance with owner flectra;"
      • make sure to name the database the same as in production as it is used in file store paths.
    • "pg_restore -h localhost  -U flectra -W -d finance ~/Downloads/finance.dump"

Filestore Setup

  • Download the filestore under "/var/lib/flrectra/.local/share/Flectra/filestore". Probably best to create a tar file and copy that over.
  • Copy the filestore to /var/lib/odoo/.local/share/Odoo/filestore
    • "sudo cp -a ./var/lib/flectra/.local/share/Flectra/filestore /var/lib/odoo/.local/share/Odoo/"
  • Change ownership to Odoo:Odoo
    • "sudo chown -R odoo:odoo /var/lib/odoo/.local/share/Odoo/filestore/"

Note: The /var/lib/odoo/.local/share/Odoo/filestore directory will not exist until you run Odoo so you may need to create it or run odoo to create it then stop odoo and copy over the files.

Update and Install Custom modules 

We don't know a whole lot about Odoo and Flectra internals and development but have written some basic modules. This processes is teaching us a whole lot about Flectra's internals we wish we didn't need to know but it all helps in the long-run.

  • Copy over your custom modules. We grouped them in an addons-upgrade directory.
  • Update references to Flectra to Odoo
    • "grep -ilR flectra ./ | egrep -v 'git' | xargs -n 1  sed -i 's/flectra/odoo/g'"
    • "grep -ilR 'fpl-1' ./ | grep -v git | xargs -n 1 sed -i 's/FPL-1/OPL-1/';"
      • this is to stop complaints about licenses during the upgrade
  • Finally, copy over the custom modules to the addons directory
    • sudo cp -a ~/addons-upgrade/*  /usr/lib/python3/dist-packages/odoo/addons/

Note: The addons directory will not exist until you install Odoo.

We had to edit "views.xml" , "templates.xml" and models  to accommodate changes between versions of Odoo. This is something that will be different for your custom modules. Our modules are simple so it was mainly related to xpath queries to change the layout templates. We did find that, on occasion, we needed to delete the entries from ir_ui_view in order for changes to templates.xml to be loaded despite running an update.

  • "delete from ir_ui_view where id in (1554,2126);"

Install the version of Odoo you are upgrading to

  • Download Odoo 
    • wget https://nightly.odoo.com/12.0/nightly/deb/odoo_12.0.latest_all.deb
  • Install the python dependencies (you can probably skip this and fix it with the last 2 steps)
    • "sudo apt install python3-docutils python3-feedparser python3-gevent python3-html2text python3-mock python3-ofxparse python3-passlib python3-psutil python3-pydot python3-pypdf2 python3-serial python3-suds python3-usb  python3-werkzeug python3-xlsxwriter node-less  python3-vatnumber python3-num2words python3-babel  python3-decorator  python3-jinja2 python3-mako python3-psycopg2 postgresql-client python3-ldap python3-pip pyldap qrcode xlwt vobject -y"
  • Install Odoo
    • "sudo dpkg -i odoo_12.0.latest_all.deb"
    • "sudo apt install --fix-broken"
      • this will resolve the broken install you will get from the step above
  • Edit /etc/odoo/odoo.conf as appropriate
    • [options]
      ; This is the password that allows database operations:
      ; admin_passwd = admin
      db_host = localhost
      db_port = 5432
      db_user = flectra
      db_password = flectra
      ;addons_path = /usr/lib/python3/dist-packages/odoo/addons
    Install these python modules that may be needed later
    • "sudo pip install pyldap qrcode xl

Install OpenUpgrade

Next, we need to install OpenUpgrade. The OpenUpgrade library is required by the OpenUpgrade scripts.  As far as we can tell this needs to be installed separately from the GitHub repository. Don't use the library that comes with Ubuntu 20.04 instead install the latest version with:

  • sudo -H pip3 install --ignore-installed git+https://github.com/OCA/openupgradelib.git@master

Next, we need to clone the github repo and switch to the right branch for the upgrade. In this case (Flectra 1.7 (Odoo 11) to Odoo 12)

  • git clone https://github.com/OCA/OpenUpgrade.git
  • git switch -c 12.0 origin/12.0

Install The Odoo Versions of Any 3rd Party Modules

We use the account financial report module amongst others. We didn't find versions of all the 3rd party modules that we used in Flectra. This is probably the cause of some of the issues we have experienced.

  • sudo cp account_financial_report-12.0.1.5.2.zip  /var/lib/odoo/.local/share/Odoo/addons/12.0/
  • sudo unzip  /var/lib/odoo/.local/share/Odoo/addons/12.0/account_financial_report-12.0.1.5.2.zip
  • sudo chown odoo:odoo

Ready, Set, Go

We will assume the steps to upgrade complete for now. As you may suspect, running the upgrades steps is where most of the work lies and we will document the challenges we came across in the following sections.

  • Stop the odoo service.
    • "sudo systemctl stop odoo"
  • Run the OpenUpgrade script from within the OpenUpgrade directory.
    • "sudo .Openupgrade/odoo-bin -c /etc/odoo/odoo.conf --data-dir /var/lib/odoo/.local/share/Odoo  --database finance --update=all --stop-after-init"
  • Next run the  Odoo Upgrade (Note we are running odoo11 not OpenUpgrade binary)
    • "sudo odoo -c /etc/odoo/odoo.conf --data-dir /var/lib/odoo/.local/share/Odoo  --database finance --update=all --stop-after-init"
  • Start Odoo
    • "sudo systemctl start odoo"

Profit?

Not quite. As you can guess the upgrade steps don't go according to plan..

Issues Before the Upgrade

Before we began the upgrade to Odoo 12.  We ran an update on Flectra 1.7 to make sure the database was up-to-date.

  • "sudo odoo -c /etc/odoo/odoo.conf --data-dir /var/lib/odoo/.local/share/Odoo  --database finance --update=all --stop-after-init"

Felctra 1.7 Theme Update Errors

During this process, we got errors updating the themes. Theme Art, Hermit, Techperspective etc were noted as not upgraded due to being incompatible. We got the same error attempting to update them via the web interface. We tried uninstalling them and then reinstalling them. We managed to get Theme Art to install, at least according to the web interface. None of the other themes would install though. Strangely it didn't seem to bother the e-commerce that their themes were missing. We have multiple e-commerce sites and we cannot use the same theme on different sites and so had to install a different theme for each site. So before the upgrade only Theme Art was installed even though other sites where using "Theme Hermit" etc. So there is some issue here that may be causing issues with our upgrade. Anyone else had these problems with theme and Flectra 1.7?

Issues Upgrading from Flectra 1.7 to Odoo 12

We got several errors during the OpenUpgrade process.

  • The process halted with an error about an insert into the name column on the product_template table being null.  The insert appears to be part of account_invoice migration. There is a line from a purchase invoice that the process wants to create a product template for. Its for a tip on a lunch bill. I have no idea why. There are two rows with this problem. We got around this by adding a default value to the column with:
    • "alter table product_template alter column name set  default  'change me'";
  • We got errors when the upgrade script tries to delete some lines from ir_ui_menu. The delete fails due to a foreign key on the menu_bookmark table. We delete the entries from menu_bookmark.  It might be a good idea to just unbookmark everything in production before backing up the database.
    • "delete  from menu_bookmark where menu_id=365;" -> Your menu_id will be different.
  • We had an error when the process was trying to delete an line from the res_country table for Romania as it was referenced from res_partners. I found the account and updated its address to point to another country and will come back and switch it back once done.
    • "update  res_partner set country_id=27, state_id =339 where id = 2879;"
  • It complained about duplicates in the product_wishlist so I found and deleted those.
    • "delete from product_wishlist where id in  (620,572,334);"
  • For one of our modules we needed to update references to the class WebsiteSalesOption with WebsiteSale as this had been merged in 12.0

After this the OpenUpgrade process ran to the end but the following modules were not upgraded.

  • module base_branch_company 
  • module account_bank_statement_import_ofx 
  • module account_discount 
  • module theme_art 
  • module currency_rate_update 
  • module account_asset_management 
  • module sales_discount 
  • module account_cash_flow 
  • module payment_payweb_3 

We will need to check the ir_module_module table to see if we can work out the modules we need here, mapping from Flectra to Odoo.

Running Odoo 12

I edited my client's host file to point to the upgrade server to ensure that any url would be mapped correctly and then started the Odoo service and access the website with http://url:8069

The first page looked promising and had only minor style issues but upon logging in numerous errors were presented. We suspect most of these relate to the missing modules.

  • When browsing to /shop we get 500 errors. The following is in odoo-server.log
    • KeyError: ('ir.qweb', <function IrQWeb.compile at 0x7f96da9f59d0>, 'website_sale.product_view_switcher', ('en_US', None, None, None, False, 2))
    • KeyError: ('ir.ui.view', <function View.get_view_id at 0x7f96d3866dc0>, 4, 'website_sale.product_view_switcher', (2,))
    • ValueError: View 'website_sale.product_view_switcher' in website 2 not found
  • When browsing to /web we get a pop up with:
  • "Could not get content for /account_asset/static/src/less/account_asset.less defined in bundle 'web.assets_backend'."
  • Closing the above pop-up we get other errors depending on the menu item selected. Here are some of them.
    • Inventory -> Master Data
      • ValueError: Field `asset_category_id` does not exist

We will be updating this post before documenting our process from 12 to 13. We are unsure if we need to resolve all these problems in 12 before upgrading to 13 and then 14. Can we just ignore the missing modules until we get to Flectra 2 where they will be available again?

We continued to upgrade from Odoo 12 to Odoo 13 and overcome some obstacles there but we still got a way to go to get to Flectra2 and see if it all works. We will document these in a later post too. Please share your stories and experiences.

Blogs