[IMP] odoo.sh: Python libraries and packages

Added a note on packages and extensions support

closes odoo/documentation#3184

Taskid: 2836438
X-original-commit: b1f92ba879
Signed-off-by: Aarab Tom (toaa) <toaa@odoo.com>
This commit is contained in:
Tom Aarab (toaa) 2022-12-09 10:38:52 +00:00
parent 3c9b87be30
commit 3337ffa6c7

View File

@ -1,14 +1,14 @@
==================================
=================
Your first module
==================================
=================
Overview
========
This chapter helps you to create your first Odoo module and deploy it in your Odoo.sh project.
This tutorial requires :ref:`you created a project on Odoo.sh <odoosh-gettingstarted-create>`, and you know your Github repository's URL.
This tutorial requires :ref:`you created a project on Odoo.sh <odoosh-gettingstarted-create>`, and
you know your Github repository's URL.
Basic use of Git and Github is explained.
@ -95,8 +95,8 @@ Or, from your computer, if you have an :ref:`installation of Odoo <setup/install
$ ./odoo-bin scaffold my_module ~/src/odoo-addons/
If you do not want to bother installing Odoo on your computer,
you can also :download:`download this module structure template <first_module/my_module.zip>` in which you replace every occurrences of
*my_module* to the name of your choice.
you can also :download:`download this module structure template <first_module/my_module.zip>` in
which you replace every occurrences of *my_module* to the name of your choice.
The below structure will be generated:
@ -121,9 +121,9 @@ The below structure will be generated:
.. Warning::
Do not use special characters other than the underscore ( _ ) for your module name, not even an hyphen ( - ).
This name is used for the Python classes of your module,
and having classes name with special characters other than the underscore is not valid in Python.
Do not use special characters other than the underscore ( _ ) for your module name, not even an
hyphen ( - ). This name is used for the Python classes of your module, and having classes name
with special characters other than the underscore is not valid in Python.
Uncomment the content of the files:
@ -180,8 +180,8 @@ The above command is explained in the section
<odoosh-gettingstarted-online-editor-push>` of the
:ref:`Online Editor <odoosh-gettingstarted-online-editor>`
chapter.
It includes the explanation regarding the fact you will be prompted to type your username and password,
and what to do if you use the two-factor authentication.
It includes the explanation regarding the fact you will be prompted to type your username and
password, and what to do if you use the two-factor authentication.
Or, from your computer terminal:
@ -217,7 +217,8 @@ Once the database ready, you can access it by clicking the *Connect* button.
:align: center
If your Odoo.sh project is configured to install your module automatically,
you will directly see it amongst the database apps. Otherwise, it will be available in the apps to install.
you will directly see it amongst the database apps. Otherwise, it will be available in the apps to
install.
You can then play around with your module, create new records and test your features and buttons.
@ -232,7 +233,8 @@ you can test it with the production data using a staging branch.
You can either:
* Make your development branch a staging branch, by drag and dropping it onto the *staging* section title.
* Make your development branch a staging branch, by drag and dropping it onto the *staging* section
title.
.. image:: first_module/firstmodule-test-devtostaging.png
:align: center
@ -244,8 +246,8 @@ You can either:
You can also use the :code:`git merge` command to merge your branches.
This will create a new staging build, which will duplicate the production database and make it run using a server
updated with your latest changes of your branch.
This will create a new staging build, which will duplicate the production database and make it run
using a server updated with your latest changes of your branch.
.. image:: first_module/firstmodule-test-mergedinstaging.png
:align: center
@ -257,11 +259,13 @@ Once the database ready, you can access it using the *Connect* button.
Install your module
-------------------
Your module will not be installed automatically, you have to install it from the apps menu.
Indeed, the purpose of the staging build is to test the behavior of your changes as it would be on your production,
and on your production you would not like your module to be installed automatically, but on demand.
Your module will not be installed automatically, you have to install it from the apps menu. Indeed,
the purpose of the staging build is to test the behavior of your changes as it would be on your
production, and on your production you would not like your module to be installed automatically, but
on demand.
Your module may not appear directly in your apps to install either, you need to update your apps list first:
Your module may not appear directly in your apps to install either, you need to update your apps
list first:
* Activate the :ref:`developer mode <developer-mode>`
* in the apps menu, click the *Update Apps List* button,
@ -307,14 +311,16 @@ you have to install it manually as explained in the
Add a change
============
This section explains how to add a change in your module by adding a new field in a model and deploy it.
This section explains how to add a change in your module by adding a new field in a model and deploy
it.
From the Odoo.sh editor,
* browse to your module folder *~/src/user/my_module*,
* then, open the file *models/models.py*.
Or, from your computer,
* use the file browser of your choice to browse to your module folder *~/src/odoo-addons/my_module*,
* use the file browser of your choice to browse to your module folder
*~/src/odoo-addons/my_module*,
* then, open the file *models/models.py* using the editor of your choice,
such as *Atom*, *Sublime Text*, *PyCharm*, *vim*, ...
@ -350,8 +356,8 @@ and modify a view stored in database.
In order to be applied in existing databases, such as your production database,
these changes requires the module to be updated.
If you would like the update to be performed automatically by the Odoo.sh platform when you push your changes,
increase your module version in its manifest.
If you would like the update to be performed automatically by the Odoo.sh platform when you push
your changes, increase your module version in its manifest.
Open the module manifest *__manifest__.py*.
@ -367,7 +373,8 @@ with
'version': '0.2',
The platform will detect the change of version and trigger the update of the module upon the new revision deployment.
The platform will detect the change of version and trigger the update of the module upon the new
revision deployment.
Browse to your Git folder.
@ -414,10 +421,10 @@ The platform will then create a new build for the branch *feature-1*.
.. image:: first_module/firstmodule-test-addachange-build.png
:align: center
Once you tested your changes, you can merge your changes in the production branch, for instance by drag-and-dropping the
branch on the production branch in the Odoo.sh interface. As you increased the module version in the manifest,
the platform will update the module automatically and your new field will be directly available.
Otherwise you can manually update the module within the apps list.
Once you tested your changes, you can merge your changes in the production branch, for instance by
drag-and-dropping the branch on the production branch in the Odoo.sh interface. As you increased the
module version in the manifest, the platform will update the module automatically and your new field
will be directly available. Otherwise you can manually update the module within the apps list.
Use an external Python library
==============================
@ -425,10 +432,18 @@ Use an external Python library
If you would like to use an external Python library which is not installed by default,
you can define a *requirements.txt* file listing the external libraries your modules depends on.
.. note::
- It is not possible to install or upgrade system packages on an Odoo.sh database (e.g., apt
packages). However, under specific conditions, packages can be considered for installation.
This also applies to **Python modules** requiring system packages for their compilation, and
**third-party Odoo modules**.
- **PostgreSQL extensions** are not supported on Odoo.sh.
- For more information, consult our `FAQ <https://www.odoo.sh/faq#install_dependencies>`_.
The platform will use this file to automatically install the Python libraries your project needs.
The feature is explained in this section by using the `Unidecode library <https://pypi.python.org/pypi/Unidecode>`_ in
your module.
The feature is explained in this section by using the `Unidecode library
<https://pypi.python.org/pypi/Unidecode>`_ in your module.
Create a file *requirements.txt* in the root folder of your repository
@ -442,8 +457,8 @@ Add
unidecode
Then use the library in your module, for instance to remove accents from characters in the name field of your
model.
Then use the library in your module, for instance to remove accents from characters in the name
field of your model.
Open the file *models/models.py*.