2024-04-09 16:54:08 +07:00
|
|
|
===========
|
|
|
|
Setup guide
|
|
|
|
===========
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2023-05-09 23:01:35 +07:00
|
|
|
Depending on the intended use case, there are multiple ways to install Odoo. For developers of the
|
|
|
|
Odoo community and Odoo employees alike, the preferred way is to perform a source install
|
|
|
|
(:dfn:`running Odoo from the source code`).
|
|
|
|
|
2024-04-09 16:54:08 +07:00
|
|
|
.. important::
|
|
|
|
Follow the :ref:`contributing/development/setup` section of the contributing guide to prepare
|
|
|
|
your environment for pushing local changes to the Odoo repositories.
|
2023-05-09 23:01:35 +07:00
|
|
|
|
2024-04-09 16:54:08 +07:00
|
|
|
Adapt the environment for the tutorials
|
|
|
|
=======================================
|
2023-05-09 23:01:35 +07:00
|
|
|
|
|
|
|
By now, you should have downloaded the source code into two local repositories, one for `odoo/odoo`
|
2024-03-01 21:52:52 +07:00
|
|
|
and one for `odoo/enterprise`. These repositories are set up to push changes to pre-defined
|
2023-05-09 23:01:35 +07:00
|
|
|
forks on GitHub. This will prove to be convenient when you start contributing to the codebase, but
|
2024-04-09 16:54:08 +07:00
|
|
|
in the scope of following a tutorial, we want to avoid polluting them with training material. Let's
|
|
|
|
then push your changes in a third repository: `odoo/tutorials`. Like the first two repositories, it
|
|
|
|
will be part of the `addons-path` that references all directories containing Odoo modules.
|
2024-03-01 21:52:52 +07:00
|
|
|
|
|
|
|
.. note::
|
2024-04-09 16:54:08 +07:00
|
|
|
Depending on the tutorial that you are following, you might not need to install all the modules
|
|
|
|
that this repository contains.
|
2023-05-09 23:01:35 +07:00
|
|
|
|
2024-03-01 21:52:52 +07:00
|
|
|
#. Following the same process as with the `odoo/odoo` and `odoo/enterprise` repositories, clone
|
|
|
|
the `odoo/tutorials` repository on your machine with:
|
2022-07-04 22:12:49 +07:00
|
|
|
|
|
|
|
.. code-block:: console
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2024-03-01 21:52:52 +07:00
|
|
|
$ git clone git@github.com:odoo/tutorials.git
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2024-03-01 21:52:52 +07:00
|
|
|
#. Configure your fork and Git to push changes to your fork rather than to the main codebase. If you
|
|
|
|
work at Odoo, configure Git to push changes to the shared fork created on the account **odoo-dev**.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2024-03-01 21:52:52 +07:00
|
|
|
.. tabs::
|
|
|
|
|
|
|
|
.. tab:: Link Git with your fork
|
|
|
|
|
|
|
|
#. Visit `github.com/odoo/tutorials <https://github.com/odoo/tutorials>`_ and click the
|
|
|
|
:guilabel:`Fork` button to create a fork of the repository on your account.
|
|
|
|
|
|
|
|
#. In the command below, replace `<your_github_account>` with the name of the GitHub account
|
|
|
|
on which you created the fork.
|
|
|
|
|
|
|
|
.. code-block:: console
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2024-03-01 21:52:52 +07:00
|
|
|
$ cd /TutorialsPath
|
|
|
|
$ git remote add dev git@github.com:<your_github_account>/tutorials.git
|
|
|
|
|
|
|
|
.. tab:: Link Git with odoo-dev
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ cd /tutorials
|
|
|
|
$ git remote add dev git@github.com:odoo-dev/tutorials.git
|
|
|
|
$ git remote set-url --push origin you_should_not_push_on_this_repository
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2023-05-09 23:01:35 +07:00
|
|
|
That's it! Your environment is now prepared to run Odoo from the sources, and you have successfully
|
2024-03-01 21:52:52 +07:00
|
|
|
created a repository to serve as an addons directory. This will allow you to push your work to GitHub.
|
|
|
|
|
|
|
|
.. important::
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2024-03-01 21:52:52 +07:00
|
|
|
**For Odoo employees only:**
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2024-03-01 21:52:52 +07:00
|
|
|
#. Make sure to read very carefully :ref:`contributing/development/first-contribution`. In particular,
|
|
|
|
your branch name must follow our conventions.
|
|
|
|
|
|
|
|
#. Once you have pushed your first change to the shared fork on **odoo-dev**, create a
|
|
|
|
:abbr:`PR (Pull Request)`. Please put your quadrigram in the PR title (e.g., "abcd - Technical
|
|
|
|
Training").
|
|
|
|
|
|
|
|
This will enable you to share your upcoming work and receive feedback from your coaches. To ensure
|
|
|
|
a continuous feedback loop, we recommend pushing a new commit as soon as you complete a chapter
|
|
|
|
of the tutorial. Note that the PR is automatically updated with commits you push to **odoo-dev**,
|
|
|
|
you don't need to open multiple PRs.
|
|
|
|
|
|
|
|
#. At Odoo we use `Runbot <https://runbot.odoo.com>`_ extensively for our :abbr:`CI (Continuous
|
|
|
|
Integration)` tests. When you push your changes to **odoo-dev**, Runbot creates a new build
|
|
|
|
and test your code. Once logged in, you will be able to see your branches `Tutorials project
|
|
|
|
<https://runbot.odoo.com/runbot/tutorials-12>`_.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2023-05-09 23:01:35 +07:00
|
|
|
.. note::
|
2024-03-01 21:52:52 +07:00
|
|
|
|
2023-05-09 23:01:35 +07:00
|
|
|
The specific location of the repositories on your file system is not crucial. However, for the
|
|
|
|
sake of simplicity, we will assume that you have cloned all the repositories under the same
|
|
|
|
directory. If this is not the case, make sure to adjust the following commands accordingly,
|
|
|
|
providing the appropriate relative path from the `odoo/odoo` repository to the
|
2024-03-01 21:52:52 +07:00
|
|
|
`odoo/tutorials` repository.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
Run the server
|
|
|
|
==============
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Launch with `odoo-bin`
|
|
|
|
----------------------
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Once all dependencies are set up, Odoo can be launched by running `odoo-bin`, the command-line
|
|
|
|
interface of the server.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ cd $HOME/src/odoo/
|
2024-03-01 21:52:52 +07:00
|
|
|
$ ./odoo-bin --addons-path="addons/,../enterprise/,../tutorials" -d rd-demo
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
There are multiple :ref:`command-line arguments <reference/cmdline/server>` that you can use to run
|
|
|
|
the server. In this training you will only need some of them.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: -d <database>
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
The database that is going to be used.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: --addons-path <directories>
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
A comma-separated list of directories in which modules are stored. These directories are scanned
|
|
|
|
for modules.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: --limit-time-cpu <limit>
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Prevent the worker from using more than <limit> CPU seconds for each request.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: --limit-time-real <limit>
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Prevent the worker from taking longer than <limit> seconds to process a request.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
.. 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 '<MODULE_NAME>' has no attribute
|
|
|
|
'<$ATTRIBUTE'>`. In this case, you may need to re-install the module with :command:`$ pip
|
|
|
|
install --upgrade --force-reinstall <MODULE_NAME>`.
|
|
|
|
| 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:
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
.. code-block:: console
|
2022-06-10 21:12:31 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
$ cd $HOME/.local/lib/python3.8/site-packages/
|
|
|
|
$ find -name '*.pyc' -type f -delete
|
2022-06-10 21:12:31 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
- Other commonly used arguments are:
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
- :option:`-i <odoo-bin --init>`: Install some modules before running the server
|
2024-03-01 21:52:52 +07:00
|
|
|
(comma-separated list). This is equivalent to going to :guilabel:`Apps` in the user interface,
|
|
|
|
and installing the module from there.
|
2022-07-04 22:12:49 +07:00
|
|
|
- :option:`-u <odoo-bin --update>`: Update some modules before running the server
|
2024-03-01 21:52:52 +07:00
|
|
|
(comma-separated list). This is equivalent to going to :guilabel:`Apps` in the user interface,
|
|
|
|
selecting a module, and upgrading it from there.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
Log in to Odoo
|
|
|
|
--------------
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Open http://localhost:8069/ on your browser. We recommend using `Chrome
|
|
|
|
<https://www.google.com/intl/en/chrome/>`_, `Firefox <https://www.mozilla.org/firefox/new/>`_, or
|
|
|
|
any other browser with development tools.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
To log in as the administrator user, use the following credentials:
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
- email: `admin`
|
|
|
|
- password: `admin`
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Enable the developer mode
|
|
|
|
=========================
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
The developer or debug mode is useful for training as it gives access to additional (advanced)
|
2024-04-09 16:54:08 +07:00
|
|
|
tools. :ref:`Enable the developer mode <developer-mode>` now. Choose the method that you prefer;
|
|
|
|
they are all equivalent.
|
2022-04-13 13:36:51 +07:00
|
|
|
|
2021-05-11 17:57:39 +07:00
|
|
|
Extra tools
|
|
|
|
===========
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Useful Git commands
|
|
|
|
-------------------
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Here are some useful Git commands for your day-to-day work.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
- | Switch branches:
|
|
|
|
| When you switch branches, both repositories (odoo and enterprise) must be synchronized, i.e.
|
|
|
|
both need to be in the same branch.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ cd $HOME/src/odoo
|
2022-11-25 23:30:48 +07:00
|
|
|
$ git switch {BRANCH}
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
$ cd $HOME/src/enterprise
|
2022-11-25 23:30:48 +07:00
|
|
|
$ git switch {BRANCH}
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
- Fetch and rebase:
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
.. code-block:: console
|
2021-09-14 21:14:56 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
$ cd $HOME/src/odoo
|
|
|
|
$ git fetch --all --prune
|
2022-11-25 23:30:48 +07:00
|
|
|
$ git rebase --autostash odoo/{BRANCH}
|
2021-09-14 21:14:56 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
$ cd $HOME/src/enterprise
|
|
|
|
$ git fetch --all --prune
|
2022-11-25 23:30:48 +07:00
|
|
|
$ git rebase --autostash enterprise/{BRANCH}
|
2022-07-04 22:12:49 +07:00
|
|
|
|
|
|
|
Code Editor
|
|
|
|
-----------
|
|
|
|
|
|
|
|
If you are working at Odoo, many of your colleagues are using `VSCode
|
|
|
|
<https://code.visualstudio.com>`_, `VSCodium <https://vscodium.com>`_ (the open source equivalent),
|
|
|
|
`PyCharm <https://www.jetbrains.com/pycharm/download/#section=linux>`_, or `Sublime Text
|
|
|
|
<https://www.sublimetext.com>`_. However, you are free to choose your preferred editor.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
For JavaScript, we use ESLint and you can find a `configuration file example here
|
|
|
|
<https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines#use-a-linter>`_.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
Administrator tools for PostgreSQL
|
2023-02-13 22:50:13 +07:00
|
|
|
----------------------------------
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
You can manage your PostgreSQL databases using the command line as demonstrated earlier or using
|
2022-07-04 22:12:49 +07:00
|
|
|
a GUI application such as `pgAdmin <https://www.pgadmin.org/download/pgadmin-4-apt/>`_ or `DBeaver
|
|
|
|
<https://dbeaver.io/>`_.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
To connect the GUI application to your database we recommend you connect using the Unix socket.
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
- Host name/address: `/var/run/postgresql`
|
|
|
|
- Port: `5432`
|
|
|
|
- Username: `$USER`
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
Python Debugging
|
|
|
|
----------------
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
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.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-01-21 17:12:21 +07:00
|
|
|
You can use a classic Python library debugger (`pdb <https://docs.python.org/3/library/pdb.html>`_,
|
2022-07-04 22:12:49 +07:00
|
|
|
`pudb <https://pypi.org/project/pudb/>`_ or `ipdb <https://pypi.org/project/ipdb/>`_), or you can
|
|
|
|
use your editor's debugger.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
In the following example we use ipdb, but the process is similar with other libraries.
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
#. Install the library:
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
.. code-block:: console
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
pip install ipdb
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
#. Place a trigger (breakpoint):
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
.. code-block:: python
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
import ipdb; ipdb.set_trace()
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
.. example::
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
.. code-block:: python
|
|
|
|
:emphasize-lines: 2
|
2021-05-11 17:57:39 +07:00
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
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)
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
Here is a list of commands:
|
|
|
|
|
|
|
|
.. option:: h(elp) [command]
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Print the list of available commands if not argument is supplied. With a command as an argument,
|
|
|
|
print the help about that command.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: pp expression
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
The value of the `expression` is pretty-printed using the `pprint` module.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: w(here)
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Print a stack trace with the most recent frame at the bottom.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: d(own)
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Move the current frame one level down in the stack trace (to a newer frame).
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: u(p)
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Move the current frame one level up in the stack trace (to an older frame).
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: n(ext)
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Continue the execution until the next line in the current function is reached or it returns.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: c(ontinue)
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Continue the execution and only stop when a breakpoint is encountered.
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: s(tep)
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
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).
|
2021-05-11 17:57:39 +07:00
|
|
|
|
|
|
|
.. option:: q(uit)
|
|
|
|
|
2022-07-04 22:12:49 +07:00
|
|
|
Quit the debugger. The program being executed is aborted.
|