How to set up a development environment with PyCharm?

  • language
  • type
  • info created for version
      8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , 16.0
Add to Cart

In the file manager

  • Create an Odoo/[version].0 folder and clone Odoo there with the command 'git clone --depth 1 --branch [version].0'. Do the same for the enterprise code if you need it (git clone --depth 1 --branch [version].0
  • Create a virtual environment in that folder (with Python3.8 since Odoo 11, with Python3.10 since Odoo 17 (+sudo apt-get install python3.10-dev)) ...
    • virtualenv ./venv -p /usr/bin/python3.8/3.10 or python3.8/3.10 -m venv ./venv
    • source ./venv/bin/activate
    • pip3 install -r odoo/requirements.txt (If psycopg2 is version 2.7.1 in this file, set it to first.)
    • deactivate
  • In Pycharm

  • Open the Odoo/[version].0 folder ...
    • Change the standard Python interpreter of your project to the newly created environment ... File > Settings > Project: Odoo/[version].0 > Python Interpreter > Cog icon + Add > Select Odoo/[version].0/venv/bin/python3.8.
    • Make a run configuration ...
      • + Python
      • Script path = Odoo/[version].0/odoo/odoo -bin (or openerp-server before Odoo10)
      • Parameters (do not copy/paste these params, the format could be wrong ... they should start with two hyphens)
        • Odoo should be able to connect to your database, so make sure the params --db_user and --db_password are correctly set.
        • If you have more environments of Odoo or even different versions, it's a good idea to force the selection of the correct database by setting --db-filter=^database_name$ as a parameter.
        • If you want your changes directly read from your XML files instead of from the database (as is the default behavior) you should add --dev=xml.
  • (Could not execute command 'lessc' => sudo apt-get install node-less!)

    If you want to run Odoo via the Python Terminal use the following command ...

    (venv) osadmin@osadmin-NJ50-70CU:~/OdooProjects/Odoo/[version].0/odoo$ python odoo-bin shell -d database_name --addons-path=addons,../enterprise,..

    And now you can run inspect Odoo in the terminal like ... => 'Odoobot'