odoo / docker

Other
931 stars 1.51k forks source link

Issues Migrating Using OpenUpgrade #432

Open jamesstidard opened 1 year ago

jamesstidard commented 1 year ago

Hi,

I initially posted this on OCA/OpenUpgrade, but it was closed and suggested I ask for help here.

I'm trying to migrate my odoo:14 over to odoo:15 using https://github.com/OCA/OpenUpgrade. Hopefully someones done something similar in the past, or can see the mistake I'm making.

Here's the re-port of the issue:

I'm trying to upgrade from v14 to v15. I'm also using the docker image of odoo.

I'm following the documentation here.

The error I get is:

odoo@e26e5e68fa7e:/$ odoo --update=all --config=/etc/odoo/odoo.conf --stop-after-init --load=base,web,openupgrade_framework
2023-01-05 13:00:20,599 79 INFO ? odoo: Odoo version 14.0-20221226 
2023-01-05 13:00:20,600 79 INFO ? odoo: Using configuration file at /etc/odoo/odoo.conf 
2023-01-05 13:00:20,600 79 INFO ? odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/var/lib/odoo/addons/14.0', '/mnt/extra-addons'] 
2023-01-05 13:00:20,600 79 INFO ? odoo: database: odoo@database:5432 
2023-01-05 13:00:20,726 79 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf 
2023-01-05 13:00:20,858 79 CRITICAL ? odoo.modules.module: Couldn't load module openupgrade_framework 
2023-01-05 13:00:20,858 79 CRITICAL ? odoo.modules.module: type object 'NameManager' has no attribute 'check' 
2023-01-05 13:00:20,858 79 ERROR ? odoo.service.server: Failed to load server-wide module `openupgrade_framework`. 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/service/server.py", line 1151, in load_server_wide_modules
    odoo.modules.module.load_openerp_module(m)
  File "/usr/lib/python3/dist-packages/odoo/modules/module.py", line 385, in load_openerp_module
    __import__('odoo.addons.' + module_name)
  File "/mnt/extra-addons/openupgrade_framework/__init__.py", line 7, in <module>
    from . import odoo_patch
  File "/mnt/extra-addons/openupgrade_framework/odoo_patch/__init__.py", line 1, in <module>
    from . import odoo
  File "/mnt/extra-addons/openupgrade_framework/odoo_patch/odoo/__init__.py", line 1, in <module>
    from . import addons, api, models, modules
  File "/mnt/extra-addons/openupgrade_framework/odoo_patch/odoo/addons/__init__.py", line 1, in <module>
    from . import base
  File "/mnt/extra-addons/openupgrade_framework/odoo_patch/odoo/addons/base/__init__.py", line 1, in <module>
    from . import models
  File "/mnt/extra-addons/openupgrade_framework/odoo_patch/odoo/addons/base/models/__init__.py", line 2, in <module>
    from . import ir_ui_view
  File "/mnt/extra-addons/openupgrade_framework/odoo_patch/odoo/addons/base/models/ir_ui_view.py", line 66, in <module>
    check._original_method = NameManager.check
AttributeError: type object 'NameManager' has no attribute 'check'
2023-01-05 13:00:20,872 79 INFO ? odoo.service.server: Initiating shutdown 
2023-01-05 13:00:20,872 79 INFO ? odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown. 

So this is saying it's unable to find the openupgrade_framework, though I've copied the openupgrade_framework and openupgrade_scripts modules into the /mnt/extra-addons directory.

The dockers /etc/odoo/odoo.conf options.addons_path is set to /mnt/extra-addons, and the modules are in there. I'm also calling the odoo command with --config=/etc/odoo/odoo.conf so that it is using that folder. You can see this in the output:

2023-01-05 13:00:20,600 79 INFO ? odoo: addons paths: ['/usr/lib/python3/dist-packages/odoo/addons', '/var/lib/odoo/addons/14.0', '/mnt/extra-addons']

The folder structure of the openupgrade_framework looks like /mnt/extra-addons/openupgrade_framework/__manifest__.py, so believe I have it properly positioned.

Unsure where to go from here. Has anyone had any experience of upgrading within the docker container, or otherwise know what could be going on here?

Here are the steps I've done and the docker-compose.yml if handy:

version: '3.1'
services:
  web:
    image: odoo:14.0
    depends_on:
      - database
    ports:
      - 8069:8069
    environment:
      - HOST=database
      - USER=odoo
      - PASSWORD=password
    volumes:
      - ./app_data:/var/lib/odoo
      - ./config:/etc/odoo
      - ./addons:/mnt/extra-addons
  database:
    image: postgres:13
    ports:
      - 5432:5432
    environment:
      - POSTGRES_DB=odoo
      - POSTGRES_PASSWORD=password
      - POSTGRES_USER=odoo
      - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
      - ./db:/var/lib/postgresql/data/pgdata
# Not a automated script, but more a list of commands
# run indavidually and tweak as nessisary
# ran from the context of the host machine, not the container.

# run the current odoo service in docker
docker-compose up --wait

# make scratch dir for OpenUpgrade codebase
mkdir -p ./scratch/

# download OpenUpgrade if not exists
[ ! -d "./scratch/OpenUpgrade" ] && git clone https://github.com/OCA/OpenUpgrade.git ./scratch/OpenUpgrade

# checkout version you want to upgrade _to_. Can only do one major version at a time
git -C ./scratch/OpenUpgrade checkout 15.0

# install lib package on running odoo web server
docker exec -it --user root odoo-web-1 apt update
docker exec -it --user root odoo-web-1 apt install -y python3-pip git
docker exec -it odoo-web-1 pip3 install wheel git+https://github.com/OCA/openupgradelib.git@master#egg=openupgradelib

# copy frameowrk/scripts to addons path
# TODO: maybe needs to go in /var/lib/odoo/addons/14 instead?
docker cp ./scratch/OpenUpgrade/openupgrade_framework odoo-web-1:/mnt/extra-addons
docker cp ./scratch/OpenUpgrade/openupgrade_scripts odoo-web-1:/mnt/extra-addons

docker exec -it odoo-web-1 odoo --update=all --config=/etc/odoo/odoo.conf --stop-after-init --load=base,web,openupgrade_framework
amh-mw commented 1 year ago

Since you are mounting over top of /etc/odoo, I don't think you can still assume that the default addons_path = /mnt/extra-addons is in effect. What do you have set for addons_path in your local ./config/odoo.conf?