From 44fd054858d61321fe9d2ba6fa7f52766c42d801 Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Mon, 4 Jul 2022 15:12:49 +0000 Subject: [PATCH] [IMP] developer/rdtraining: simplify the development environment setup In an attempt to help new developers install Odoo with a straightforward procedure, Chapter 2 of the "Getting started" tutorial included copy-pastes of parts of the "Installing Odoo" page. This proved to be inefficient because it required maintaining documentation on the installation procedure in several places and misled the readers by suggesting installing the Python requirements *after* installing PostgreSQL. With this commit, the page on Chapter 2 is refreshed to be clearer to the readers and redirect them to the "Installing Odoo" page when necessary. task-2908434 closes odoo/documentation#2440 X-original-commit: 11460f4c939eeee520c7fff152a047a4354eccbc Signed-off-by: Antoine Vandevenne (anv) --- content/administration/install/install.rst | 123 ++-- content/developer/howtos/rdtraining.rst | 2 +- .../howtos/rdtraining/01_architecture.rst | 8 +- .../developer/howtos/rdtraining/02_setup.rst | 583 +++++++----------- ...ount-settings.png => account-settings.png} | Bin .../developer/howtos/rdtraining/J_reports.rst | 2 +- 6 files changed, 305 insertions(+), 413 deletions(-) rename content/developer/howtos/rdtraining/02_setup/{userbar-account-settings.png => account-settings.png} (100%) diff --git a/content/administration/install/install.rst b/content/administration/install/install.rst index 551cda077..0ec523090 100644 --- a/content/administration/install/install.rst +++ b/content/administration/install/install.rst @@ -248,6 +248,8 @@ packaged installations, and allows overriding settings using Finally it provides greater control over the system's set up, and allows to more easily keep (and run) multiple versions of Odoo side-by-side. +.. _setup/install/source/windows: + Windows ------- @@ -270,31 +272,42 @@ Enterprise Edition: * `Official download page `_ * `GitHub repository `_ +.. _setup/install/source/windows/git: + Git ^^^ -The following requires git_ to be installed on your machine and that you have basic knowledge of -git commands. +The following requires `Git `_ to be installed on your machine and that you have basic +knowledge of Git commands. To clone a Git repository, you must choose between cloning with HTTPS or +SSH. If you do not know the difference between the two, the best option is most likely HTTPS. If you +are following the :doc:`Getting started ` developer tutorial, or plan +on contributing to Odoo source code, choose SSH. -Community Edition: +.. note:: + **The Enterprise Git repository does not contain the full Odoo source code**. It is only a + collection of extra add-ons. The main server code is in the Community version. Running the + Enterprise version actually means running the server from the Community version with the + addons-path option set to the folder with the Enterprise version. You need to clone both the + Community and Enterprise repository to have a working Odoo Enterprise installation. See + :ref:`setup/install/editions` to get access to the Enterprise repository. -.. code-block:: doscon +.. tabs:: - C:\> git clone https://github.com/odoo/odoo.git + .. tab:: Clone with HTTPS + .. code-block:: doscon -Enterprise Edition: (see :ref:`setup/install/editions` to get access) + C:\> git clone https://github.com/odoo/odoo.git + C:\> git clone https://github.com/odoo/enterprise.git -.. code-block:: doscon + .. tab:: Clone with SSH - C:\> git clone https://github.com/odoo/enterprise.git + .. code-block:: doscon -.. note:: **The Enterprise git repository does not contain the full Odoo source code**. It is only - a collection of extra add-ons. The main server code is in the Community version. Running - the Enterprise version actually means running the server from the Community version with - the addons-path option set to the folder with the Enterprise version. You need to clone - both the Community and Enterprise repository to have a working Odoo Enterprise - installation. + C:\> git clone git@github.com:odoo/odoo.git + C:\> git clone git@github.com:odoo/enterprise.git + +.. _setup/install/source/windows/prepare: Prepare ''''''' @@ -414,6 +427,8 @@ and `mydb` is the default database to serve on `localhost:8069`. .. seealso:: - :doc:`The exhaustive list of arguments for odoo-bin `. +.. _setup/install/source/linux: + Linux ----- @@ -436,31 +451,42 @@ Enterprise Edition: * `Official download page `_ * `GitHub repository `_ +.. _setup/install/source/linux/git: + Git ^^^ -The following requires git_ to be installed on your machine and that you have basic knowledge of -git commands. +The following requires `Git `_ to be installed on your machine and that you have basic +knowledge of Git commands. To clone a Git repository, you must choose between cloning with HTTPS or +SSH. If you do not know the difference between the two, the best option is most likely HTTPS. If you +are following the :doc:`Getting started ` developer tutorial, or plan +on contributing to Odoo source code, choose SSH. -Community Edition: +.. note:: + **The Enterprise Git repository does not contain the full Odoo source code**. It is only a + collection of extra add-ons. The main server code is in the Community version. Running the + Enterprise version actually means running the server from the Community version with the + addons-path option set to the folder with the Enterprise version. You need to clone both the + Community and Enterprise repository to have a working Odoo Enterprise installation. See + :ref:`setup/install/editions` to get access to the Enterprise repository. -.. code-block:: console +.. tabs:: - $ git clone https://github.com/odoo/odoo.git + .. tab:: Clone with HTTPS + .. code-block:: console -Enterprise Edition: (see :ref:`setup/install/editions` to get access) + $ git clone https://github.com/odoo/odoo.git + $ git clone https://github.com/odoo/enterprise.git -.. code-block:: console + .. tab:: Clone with SSH - $ git clone https://github.com/odoo/enterprise.git + .. code-block:: console -.. note:: **The Enterprise git repository does not contain the full Odoo source code**. It is only - a collection of extra add-ons. The main server code is in the Community version. Running - the Enterprise version actually means running the server from the Community version with - the addons-path option set to the folder with the Enterprise version. You need to clone - both the Community and Enterprise repository to have a working Odoo Enterprise - installation. + $ git clone git@github.com:odoo/odoo.git + $ git clone git@github.com:odoo/enterprise.git + +.. _setup/install/source/linux/prepare: Prepare ''''''' @@ -585,6 +611,8 @@ and `mydb` is the default database to serve on `localhost:8069`. .. seealso:: - :doc:`The exhaustive list of arguments for odoo-bin `. +.. _setup/install/source/mac_os: + Mac OS ------ @@ -607,31 +635,42 @@ Enterprise Edition: * `Official download page `_ * `GitHub repository `_ +.. _setup/install/source/mac_os/git: + Git ^^^ -The following requires git_ to be installed on your machine and that you have basic knowledge of -git commands. +The following requires `Git `_ to be installed on your machine and that you have basic +knowledge of Git commands. To clone a Git repository, you must choose between cloning with HTTPS or +SSH. If you do not know the difference between the two, the best option is most likely HTTPS. If you +are following the :doc:`Getting started ` developer tutorial, or plan +on contributing to Odoo source code, choose SSH. -Community Edition: +.. note:: + **The Enterprise Git repository does not contain the full Odoo source code**. It is only a + collection of extra add-ons. The main server code is in the Community version. Running the + Enterprise version actually means running the server from the Community version with the + addons-path option set to the folder with the Enterprise version. You need to clone both the + Community and Enterprise repository to have a working Odoo Enterprise installation. See + :ref:`setup/install/editions` to get access to the Enterprise repository. -.. code-block:: console +.. tabs:: - $ git clone https://github.com/odoo/odoo.git + .. tab:: Clone with HTTPS + .. code-block:: console -Enterprise Edition: (see :ref:`setup/install/editions` to get access) + $ git clone https://github.com/odoo/odoo.git + $ git clone https://github.com/odoo/enterprise.git -.. code-block:: console + .. tab:: Clone with SSH - $ git clone https://github.com/odoo/enterprise.git + .. code-block:: console -.. note:: **The Enterprise git repository does not contain the full Odoo source code**. It is only - a collection of extra add-ons. The main server code is in the Community version. Running - the Enterprise version actually means running the server from the Community version with - the addons-path option set to the folder with the Enterprise version. You need to clone - both the Community and Enterprise repository to have a working Odoo Enterprise - installation. + $ git clone git@github.com:odoo/odoo.git + $ git clone git@github.com:odoo/enterprise.git + +.. _setup/install/source/mac_os/prepare: Prepare ''''''' diff --git a/content/developer/howtos/rdtraining.rst b/content/developer/howtos/rdtraining.rst index 6f188a017..47d4a3625 100644 --- a/content/developer/howtos/rdtraining.rst +++ b/content/developer/howtos/rdtraining.rst @@ -3,7 +3,7 @@ .. _howto/rdtraining: =============== -Getting Started +Getting started =============== Welcome to the Getting Started Odoo tutorial! If you reached this page that means you are diff --git a/content/developer/howtos/rdtraining/01_architecture.rst b/content/developer/howtos/rdtraining/01_architecture.rst index b4f6d4cfc..bf556340a 100644 --- a/content/developer/howtos/rdtraining/01_architecture.rst +++ b/content/developer/howtos/rdtraining/01_architecture.rst @@ -122,10 +122,10 @@ Odoo is available in `two versions`_: Odoo Enterprise (licensed & shared sources functionalities to Odoo. From a technical point-of-view, these functionalities are simply new modules installed on top of the modules provided by the Community version. -Ready to start? Before writing actual code, let's go to the -:ref:`next chapter ` to review the Odoo installation process. Even if -Odoo is already running on your system, we strongly suggest you go through this chapter -to make sure we start on the same page during the development of our new application. +Ready to start? Before writing actual code, let's go to the :doc:`next chapter <02_setup>` to review +the Odoo installation process. Even if Odoo is already running on your system, we strongly suggest +you go through this chapter to make sure we start on the same page during the development of our new +application. .. _multitier architecture: https://en.wikipedia.org/wiki/Multitier_architecture diff --git a/content/developer/howtos/rdtraining/02_setup.rst b/content/developer/howtos/rdtraining/02_setup.rst index 8b4e47a19..ed8cada5c 100644 --- a/content/developer/howtos/rdtraining/02_setup.rst +++ b/content/developer/howtos/rdtraining/02_setup.rst @@ -1,335 +1,234 @@ -.. _howto/rdtraining/02_setup: +======================================== +Chapter 2: Development environment setup +======================================== -========================================= -Chapter 2: Development Environment Set-up -========================================= +Depending on the intended use case, there are multiple ways to install Odoo. This tutorial will +stick to the :ref:`source install ` (:dfn:`running Odoo from the source +code`), which is best suited for Odoo developers. -There are multiple ways to install Odoo depending on the intended use case. +Throughout this document, we assume that you are installing your development environment on a +laptop provided by Odoo with Linux Mint installed and up-to-date. If that is not the case, switch to +the appropriate section of the installation guide, depending on whether you are on :ref:`Windows +` or :ref:`Mac OS `. The steps remain +essentially the same. -This document attempts to describe the installation options for an internal Odoo R&D developer. We -assume that you are installing your development environment on a standard Odoo laptop with Linux -Mint installed and up-to-date. At the time of writing, we are using a vanilla Linux Mint 20 -(Ubuntu 20.04) as a starting point. +Set up Git +========== - -If you are using another environment, you can refer to :ref:`setup/install/source`. - - -Fetch the sources & configure git -================================= - -Install and configure git +Install and configure Git ------------------------- -The very first step of the installation process is to install the `git version control system `_ -because the Odoo source code is managed on GitHub. - -Git can be installed on `Linux `_, `Windows -`_ or `MacOS `_. - -If you're using the laptop provided to you by Odoo, Git should already be installed. If it is not, -you can install it with: +The very first step of the installation process is to install the `Git version control system +`_ because the Odoo source code is managed on `GitHub `_. .. code-block:: console - $ sudo apt install git + $ sudo apt install git -Once installed, you can set your name and email: +.. tip:: + Check if Git is installed by trying to print Git's version with the following command: + + .. code-block:: console + + $ git --version + +Once installed, register your name and email: .. code-block:: console - $ git config --global user.name "Your full name" - $ git config --global user.email "xyz@odoo.com" + $ git config --global user.name "Your full name (trigram)" + $ git config --global user.email "xyz@odoo.com" Configure GitHub ---------------- -To fetch the sources and contribute to Odoo's development you will need a GitHub account. We -recommend using your trigram (xyz) followed by '-odoo' as your username: 'xyz-odoo'. If you prefer, -you can also use your personal GitHub account. +You need a GitHub account to fetch the sources and contribute to Odoo's development. If you don't +have one yet, create it. For the username, we recommend using your trigram "xyz" (or quadrigam) +followed by '-odoo': 'xyz-odoo'. +The easiest way to authenticate with GitHub is to use an SSH connection. Using SSH authentication +allows you to connect to GitHub without supplying your username and password every time you type a +command. -The easiest way to authenticate with GitHub is to use an SSH connection. Using the SSH -authentication will allow you to connect to GitHub without supplying your username and -password every time. +.. note:: + The following step-by-step procedure is based based on the `official GitHub documentation + `_. +#. Generate a new SSH key, add it to the ssh-agent, and copy the SSH key to your clipboard. -The following instructions are based on the official `GitHub documentation `_. + .. code-block:: console + $ ssh-keygen -t ed25519 -C "xyz@odoo.com" + $ ssh-add ~/.ssh/id_ed25519 + $ sudo apt install xclip + $ xclip -sel clip < ~/.ssh/id_ed25519.pub -Here is a step-by-step procedure: +#. Go to `GitHub.com `_, then click on your profile picture in the upper-right + corner of the page and then on :guilabel:`Settings`. + .. image:: 02_setup/account-settings.png -- Generate a new SSH key, add it to the ssh-agent and copy the SSH key to your clipboard. +#. On the user settings sidebar, click on :guilabel:`SSH and GPG keys`. - .. code-block:: console + .. image:: 02_setup/settings-sidebar-ssh-keys.png - $ ssh-keygen -t ed25519 -C "xyz@odoo.com" - $ ssh-add ~/.ssh/id_ed25519 - $ sudo apt-get install xclip - $ xclip -sel clip < ~/.ssh/id_ed25519.pub +#. Click on :guilabel:`New SSH key` or on :guilabel:`Add SSH key`. + .. image:: 02_setup/ssh-add-ssh-key.png -In Github: +#. In the :guilabel:`Title` field, add a descriptive label for the new key. +#. Paste your key into the :guilabel:`Key` field. + .. image:: 02_setup/ssh-key-paste.png -- In the upper-right corner of any page, click your profile photo, then click Settings - - .. image:: 02_setup/userbar-account-settings.png - -- In the user settings sidebar, click SSH and GPG keys. - - .. image:: 02_setup/settings-sidebar-ssh-keys.png - -- Click New SSH key or Add SSH key. - - .. image:: 02_setup/ssh-add-ssh-key.png - -- In the "Title" field, add a descriptive label for the new key. -- Paste your key into the "Key" field. - - .. image:: 02_setup/ssh-key-paste.png - -- Click Add SSH key. - +#. Click on :guilabel:`Add SSH key`. Fetch the sources ------------------ +================= -All the Odoo sources will be located in `$HOME/src/` +It is time to fetch the source code of Odoo. First, let's create a home for the Git repositories in +:file:`$HOME/src/`. .. code-block:: console - $ mkdir -p $HOME/src - $ cd $HOME/src - $ git clone git@github.com:odoo/odoo.git - $ git clone git@github.com:odoo/enterprise.git + $ mkdir -p $HOME/src + $ cd $HOME/src -.. tip:: Cloning the repositories will take a while, enjoy a cup of coffee while you wait. +Then, clone the two repositories with SSH as explained in the :ref:`Installing Odoo guide +`. -.. tip:: You may need to ask your manager for read rights to fetch the enterprise repository. +.. tip:: + Cloning the repositories will take a while, enjoy a cup of coffee while you wait. .. _howto/rdtraining/02_setup/development_repository: -Configure development repository --------------------------------- +Configure the Git repositories +============================== -To contribute to Odoo's development you will need to -`fork the repository `_, create a branch containing -your code in the fork and submit a -`Pull Request `_ -to the Odoo repository. +To contribute to an Odoo repository, you first need to `fork it +`_, then create a branch +containing your changes on the fork, and finally submit a `Pull Request +`_ to the +repository. -If you are lucky enough to work at Odoo, the forks already exist. They are called -`odoo-dev/odoo` and `odoo-dev/enterprise`. +.. tip:: + If you are lucky enough to work at Odoo, the forks already exist. They are hosted on + https://github.com/odoo-dev/odoo and https://github.com/odoo-dev/enterprise. + +After your two forks are created, their remote address can be added in your local repositories. In +the commands below, replace `odoo-dev/odoo` and `odoo-dev/enterprise` with the name of your forks if +needed. .. code-block:: console - $ cd $HOME/src/odoo - $ git remote add odoo-dev git@github.com:odoo-dev/odoo.git #add odoo-dev as a new remote - $ git remote rename origin odoo #change the name of origin (the odoo repository) to odoo - $ git remote set-url --push odoo no_push #remove the possibility to push to odoo (you can only push to odoo-dev) - - $ cd $HOME/src/enterprise - $ git remote add enterprise-dev git@github.com:odoo-dev/enterprise.git - $ git remote rename origin enterprise - $ git remote set-url --push enterprise no_push - - -Useful git commands -------------------- - -Here are some useful git commands for your day-to-day work. - -* Change branch: - When you change branches, both repositories (odoo and enterprise) must be synchronized, i.e. both - need to be in the same branch. - - .. code-block:: console - - $ cd $HOME/src/odoo - $ git checkout 15.0 - - $ cd $HOME/src/enterprise - $ git checkout 15.0 - -* Fetch and rebase: - - .. code-block:: console - - $ cd $HOME/src/odoo - $ git fetch --all --prune - $ git rebase --autostash odoo/15.0 - - $ cd $HOME/src/enterprise - $ git fetch --all --prune - $ git rebase --autostash enterprise/15.0 + $ cd $HOME/src/odoo + $ git remote add odoo-dev git@github.com:odoo-dev/odoo.git # Add odoo-dev as a new remote. + $ git remote rename origin odoo # Change the name of origin (the odoo repository) to odoo. + $ git remote set-url --push odoo no_push # Remove the possibility to push directly to odoo (you can only push to odoo-dev). + $ cd $HOME/src/enterprise + $ git remote add enterprise-dev git@github.com:odoo-dev/enterprise.git + $ git remote rename origin enterprise + $ git remote set-url --push enterprise no_push Install the dependencies ======================== -Python ------- +As seen in :ref:`howto/rdtraining/01_architecture`, Odoo's server runs on Python and uses PostgreSQL +as an RDBMS. In the context of a development machine, the easiest approach is to install everything +locally. To do so, follow once again the :ref:`Installing Odoo guide +`. -Odoo requires Python 3.7 or later, if your computer is up-to-date you should already be at this -version or higher. +.. tip:: + Some useful SQL commands: -You can check your Python version with: + .. code-block:: console -.. code-block:: console + $ createdb $DB_NAME # Create a database. + $ dropdb $DB_NAME # Drop a database. - $ python3 --version - -Install pip3 and libraries --------------------------- - -For libraries using native code, installation of development tools and native dependencies is -required before installing the Python dependencies of Odoo. - -.. code-block:: console - - $ sudo apt install python3-pip python3-dev libxml2-dev libxslt1-dev libldap2-dev libsasl2-dev libssl-dev libpq-dev libjpeg-dev - - -Install odoo requirements -------------------------- - -.. code-block:: console - - $ cd $HOME/src/odoo - $ pip3 install -r requirements.txt - -.. _howto/rdtraining/02_setup/install-wkhtmltopdf: - -Install wkhtmltopdf -------------------- - -wkhtmltopdf is a library to render HTML into PDF. Odoo uses it to create PDF reports. wkhtmltopdf -is not installed through pip and must be installed manually in version 0.12.5 to support -headers and footers. - -.. code-block:: console - - $ cd /tmp/ - $ sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.focal_amd64.deb - $ sudo gdebi --n wkhtmltox_0.12.5-1.focal_amd64.deb - $ sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin - $ sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin - -Right-to-left interface support -------------------------------- - -In order to support right-to-left (RTL) languages, we need `rtlcss` to convert the CSS files: - -.. code-block:: console - - $ sudo apt-get install nodejs npm - $ sudo npm install -g rtlcss - -Install PostgreSQL ------------------- - -As seen in :ref:`howto/rdtraining/01_architecture`, Odoo uses PostgreSQL as a RDBMS. In the context of a -development machine, the easiest approach is to install it locally. Then we can create a PostgreSQL user -corresponding to our current user: - -.. code-block:: console - - $ sudo apt install postgresql postgresql-client - $ sudo -u postgres createuser -s $USER - - -Some useful SQL commands: - -.. code-block:: console - - $ createdb $DB_NAME #Create a database - $ dropdb $DB_NAME #Drop a database - - $ psql $DB_NAME #Connect to a database - \l #List all the available databases - \dt #List all the tables of the $DB_NAME database - \d $TABLE_NAME #Show the structure of the table $TABLE_NAME - \q #Quit the psql environment (ctrl + d) + $ psql $DB_NAME # Connect to a database. + \l #List all the available databases. + \dt #List all the tables of the $DB_NAME database. + \d $TABLE_NAME #Show the structure of the table $TABLE_NAME. + \q #Quit the psql environment (ctrl + d). Run the server ============== -Running odoo-bin ----------------- +Launch with `odoo-bin` +---------------------- -Once all dependencies are set up, Odoo can be launched by running odoo-bin, the command-line interface of the server. +Once all dependencies are set up, Odoo can be launched by running `odoo-bin`, the command-line +interface of the server. .. code-block:: console $ cd $HOME/src/odoo/ $ ./odoo-bin --addons-path="addons/,../enterprise/" -d rd-demo -There are multiple :ref:`command-line arguments ` that you can use to -configure the server. In this training you will only need some of them. +There are multiple :ref:`command-line arguments ` that you can use to run +the server. In this training you will only need some of them. .. option:: -d - The database that is going to be used. + The database that is going to be used. .. option:: --addons-path - A comma-separated list of directories in which modules are stored. These directories are scanned - for modules. + A comma-separated list of directories in which modules are stored. These directories are scanned + for modules. .. option:: --limit-time-cpu - Prevents the worker from using more than CPU seconds for each request. + Prevent the worker from using more than CPU seconds for each request. .. option:: --limit-time-real - Prevents the worker from taking longer than seconds to process a request. + Prevent the worker from taking longer than seconds to process a request. -The last two can be used to prevent the worker from being killed when debugging the source code. +.. tip:: + - The :option:`--limit-time-cpu` and :option:`--limit-time-real` arguments can be used to prevent + the worker from being killed when debugging the source code. + - | You may face an error similar to `AttributeError: module '' has no attribute + '<$ATTRIBUTE'>`. In this case, you may need to re-install the module with :command:`$ pip + install --upgrade --force-reinstall `. + | If this error occurs with more than one module, you may need to re-install all the + requirements with :command:`$ pip install --upgrade --force-reinstall -r requirements.txt`. + | You can also clear the python cache to solve the issue: -.. tip:: You may face an error similar to `AttributeError: module '$MODULE_NAME' has no attribute '$ATTRIBUTE'` + .. code-block:: console - In this case you may need to re-install the module with `$ pip install --upgrade --force-reinstall $MODULE_NAME` + $ cd $HOME/.local/lib/python3.8/site-packages/ + $ find -name '*.pyc' -type f -delete - If this error occurs with more than one module then you may need to re-install all the - requirements with `$ pip3 install --upgrade --force-reinstall -r requirements.txt` - - You can also clear the python cache to solve the issue - - .. code-block:: console - - $ cd $HOME/.local/lib/python3.8/site-packages/ - $ find -name '*.pyc' -type f -delete - -.. tip:: Other commonly used arguments are: - - * :option:`-i `: install some modules before running the server (comma separated list) - * :option:`-u `: update some modules before running the server (comma separated list) + - Other commonly used arguments are: + - :option:`-i `: Install some modules before running the server + (comma-separated list). + - :option:`-u `: Update some modules before running the server + (comma-separated list). Log in to Odoo -------------- -Open `http://localhost:8069/` on your browser. We recommend you use: -`Firefox `_, -`Chrome `_ -(`Chromium `_ the open source equivalent) or any other browser with -development tools. +Open http://localhost:8069/ on your browser. We recommend using `Chrome +`_, `Firefox `_, or +any other browser with development tools. -To log in as the administrator user, you can use the following credentials: +To log in as the administrator user, use the following credentials: -* email = `admin` -* password = `admin` +- email: `admin` +- password: `admin` -The developer mode -================== +Enable the developer mode +========================= -The Developer or Debug Mode gives you access to additional (advanced) tools. +The developer or debug mode is useful for training as it gives access to additional (advanced) +tools. In the next chapters, **we will always assume that you have enabled the developer mode**. -This is useful for training and we assume that the user is in developer mode for the rest of the tutorials. - -To activate the developer or debug mode you can follow the steps `here `_. +:ref:`Enable the developer mode ` now. Choose the method that you prefer; they are +all equivalent. .. note:: The main page of the Settings screen is only accessible if at least one application is installed. @@ -338,193 +237,147 @@ To activate the developer or debug mode you can follow the steps `here `_, `VSCodium `_ (the open source equivalent), +`PyCharm `_, or `Sublime Text +`_. However, you are free to choose your preferred editor. -Don't forget to configure your linters correctly. Using a linter can help you by showing syntax and semantic -warnings or errors. Odoo source code tries to respect Python and JavaScript standards, but some of -them can be ignored. +It is important to configure your linters correctly. Using a linter helps you by showing syntax and +semantic warnings or errors. Odoo source code tries to respect Python's and JavaScript's standards, +but some of them can be ignored. For Python, we use PEP8 with these options ignored: -- E501: line too long -- E301: expected 1 blank line, found 0 -- E302: expected 2 blank lines, found 1 +- `E501`: line too long +- `E301`: expected 1 blank line, found 0 +- `E302`: expected 2 blank lines, found 1 -For JavaScript, we use ESLint and you can find a `configuration file example here`_. - -If you do not know how to set up a linter: - -- `Here is an explanation of how to set up a Python linter in VSCode `_. There are multiple - linter options you are free to choose from, but `Flake8 `_ is a popular choice. -- To setup ESLint in VSCode, you must download the `ESLint extension`_ and follow its instructions - for installing ESLint. Don't forget to create and set up the `.eslintrc` file to follow the - configuration file mentioned above. -- Another useful VSCode plugin is `Trailing Spaces`_ to quickly notice trailing spaces while - you're working. - -.. _Trailing Spaces: https://marketplace.visualstudio.com/items?itemName=shardulm94.trailing-spaces -.. _ESLint extension: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint -.. _configuration file example here: https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines#use-a-linter -.. _VSCode: https://code.visualstudio.com/ -.. _VSCodium: https://vscodium.com/ -.. _Sublime Text: https://www.sublimetext.com/ -.. _PyCharm: https://www.jetbrains.com/pycharm/download/#section=linux -.. _Atom: https://atom.io/ +For JavaScript, we use ESLint and you can find a `configuration file example here +`_. Administrator tools for PostgreSQL ----------------------------------- You can manage your PostgreSQL databases using the command line as demonstrated earlier or using -a GUI application such as `pgAdmin `_ or `DBeaver `_. +a GUI application such as `pgAdmin `_ or `DBeaver +`_. To connect the GUI application to your database we recommend you connect using the Unix socket. -* Host name/address = /var/run/postgresql -* Port = 5432 -* Username = $USER - +- Host name/address: `/var/run/postgresql` +- Port: `5432` +- Username: `$USER` Python Debugging ---------------- -When facing a bug or trying to understand how the code works, simply printing things out can -go a long way, but a proper debugger can save a lot of time. +When facing a bug or trying to understand how the code works, simply printing things out can go a +long way, but a proper debugger can save a lot of time. You can use a classic Python library debugger (`pdb `_, -`pudb `_ or `ipdb `_) or you can -use your editor's debugger. To avoid difficult configurations in the beginning, it is -easier if you use a library debugger. +`pudb `_ or `ipdb `_), or you can +use your editor's debugger. In the following example we use ipdb, but the process is similar with other libraries. -- Install the library: +#. Install the library: - .. code-block:: console + .. code-block:: console - pip3 install ipdb + pip install ipdb -- Trigger (breakpoint): +#. Place a trigger (breakpoint): - .. code-block:: console + .. code-block:: python - import ipdb; ipdb.set_trace() + import ipdb; ipdb.set_trace() - Example: + .. example:: - .. code-block:: python - :emphasize-lines: 2 + .. code-block:: python + :emphasize-lines: 2 - def copy(self, default=None): - import ipdb; ipdb.set_trace() - self.ensure_one() - chosen_name = default.get('name') if default else '' - new_name = chosen_name or _('%s (copy)') % self.name - default = dict(default or {}, name=new_name) - return super(Partner, self).copy(default) + def copy(self, default=None): + import ipdb; ipdb.set_trace() + self.ensure_one() + chosen_name = default.get('name') if default else '' + new_name = chosen_name or _('%s (copy)') % self.name + default = dict(default or {}, name=new_name) + return super(Partner, self).copy(default) Here is a list of commands: .. option:: h(elp) [command] - Without an argument, print the list of available commands. With a command as an argument, print help - about that command. + Print the list of available commands if not argument is supplied. With a command as an argument, + print the help about that command. .. option:: pp expression - The value of the ``expression`` is pretty-printed using the ``pprint`` module. + The value of the `expression` is pretty-printed using the `pprint` module. .. option:: w(here) - Print a stack trace, with the most recent frame at the bottom. + Print a stack trace with the most recent frame at the bottom. .. option:: d(own) - Move the current frame one level down in the stack trace (to a newer frame). + Move the current frame one level down in the stack trace (to a newer frame). .. option:: u(p) - Move the current frame one level up in the stack trace (to an older frame). + Move the current frame one level up in the stack trace (to an older frame). .. option:: n(ext) - Continue the execution until the next line in the current function is reached or it returns. + Continue the execution until the next line in the current function is reached or it returns. .. option:: c(ontinue) - Continue the execution and only stop when a breakpoint is encountered. + Continue the execution and only stop when a breakpoint is encountered. .. option:: s(tep) - Execute the current line, stop at the first possible occasion (either in a function that is - called or on the next line in the current function). + Execute the current line. Stop at the first possible occasion (either in a function that is + called or on the next line in the current function). .. option:: q(uit) - Quit the debugger. The program being executed is aborted. + Quit the debugger. The program being executed is aborted. -.. tip:: +---- - To avoid killing the worker when debugging, you can add these arguments when launching the - server: `--limit-time-cpu=9999 --limit-time-real=9999` - Another solution is to add them directly in the `~/.odoorc` file: - - .. code-block:: console - - $ cat ~/.odoorc - [options] - limit_time_cpu = 9999 - limit_time_real = 9999 - -Additional resources --------------------- - -Below are links to resources that could prove helpful during this tutorial. - -Git -~~~ - -- Atlassian has a set of `excellent tutorials `_. - Particularly, how to `rewrite the history - `_. -- If the Atlassian tutorial does not work for you, W3schools offers a `very nice alternative - `_. -- To visualize the effect of git commands on the commits graphs, play with this `interactive - tutorial `_. -- If you want to read more about Github, their `documentation - `_ includes a comprehensive - introduction. - -Python -~~~~~~ - -- Don't forget about `Python official documentation `_ - (and make sure to select the correct version at the top of the page!). -- `The Hitchhiker's Guide `_ will teach you the good practices of - Python. -- If you have good experience of similar languages or just need a quick recall, - `this guide `_ is made for you. - -Javascript -~~~~~~~~~~ - -- You should find a tutorial that suits your level in this `"re-introduction" to JavaScript - `_. -- If you just need a quick recall, `this one `_ - will do the trick. - -(Postgre)SQL -~~~~~~~~~~~~ - -- If you are not familiar with PostgreSQL, `these exercises `_ - will teach you better than any long documentation. -- Even though you shouldn't have to interact with it, you might be interested to know - that Odoo uses `psycopg2 `_ to interact - with its SQL backend. - -Back to the training! Now that your server is running, it's time to start -:ref:`writing your own application `! +Now that your server is running, it's time to start :ref:`writing your own application +`! diff --git a/content/developer/howtos/rdtraining/02_setup/userbar-account-settings.png b/content/developer/howtos/rdtraining/02_setup/account-settings.png similarity index 100% rename from content/developer/howtos/rdtraining/02_setup/userbar-account-settings.png rename to content/developer/howtos/rdtraining/02_setup/account-settings.png diff --git a/content/developer/howtos/rdtraining/J_reports.rst b/content/developer/howtos/rdtraining/J_reports.rst index 67f494c52..919e2473c 100644 --- a/content/developer/howtos/rdtraining/J_reports.rst +++ b/content/developer/howtos/rdtraining/J_reports.rst @@ -7,7 +7,7 @@ Advanced J: PDF Reports .. warning:: This tutorial assumes you have completed the :ref:`Core Training ` - and have installed :ref:`wkhtmltopdf `. + and have installed :ref:`wkhtmltopdf `. To follow the exercise, it is recommended that you fetch the branch 15.0-core from the