[IMP] odoo.sh: Python libraries and packages
Added a note on packages and extensions support
closes odoo/documentation#3187
Taskid: 2836438
X-original-commit: b1f92ba879
Signed-off-by: Aarab Tom (toaa) <toaa@odoo.com>
This commit is contained in:
parent
6b6104f081
commit
adf0596a5f
@ -1,14 +1,14 @@
|
|||||||
|
=================
|
||||||
==================================
|
|
||||||
Your first module
|
Your first module
|
||||||
==================================
|
=================
|
||||||
|
|
||||||
Overview
|
Overview
|
||||||
========
|
========
|
||||||
|
|
||||||
This chapter helps you to create your first Odoo module and deploy it in your Odoo.sh project.
|
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.
|
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/
|
$ ./odoo-bin scaffold my_module ~/src/odoo-addons/
|
||||||
|
|
||||||
If you do not want to bother installing Odoo on your computer,
|
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
|
you can also :download:`download this module structure template <first_module/my_module.zip>` in
|
||||||
*my_module* to the name of your choice.
|
which you replace every occurrences of *my_module* to the name of your choice.
|
||||||
|
|
||||||
The below structure will be generated:
|
The below structure will be generated:
|
||||||
|
|
||||||
@ -121,9 +121,9 @@ The below structure will be generated:
|
|||||||
|
|
||||||
.. Warning::
|
.. Warning::
|
||||||
|
|
||||||
Do not use special characters other than the underscore ( _ ) for your module name, not even an hyphen ( - ).
|
Do not use special characters other than the underscore ( _ ) for your module name, not even an
|
||||||
This name is used for the Python classes of your module,
|
hyphen ( - ). This name is used for the Python classes of your module, and having classes name
|
||||||
and having classes name with special characters other than the underscore is not valid in Python.
|
with special characters other than the underscore is not valid in Python.
|
||||||
|
|
||||||
Uncomment the content of the files:
|
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
|
<odoosh-gettingstarted-online-editor-push>` of the
|
||||||
:ref:`Online Editor <odoosh-gettingstarted-online-editor>`
|
:ref:`Online Editor <odoosh-gettingstarted-online-editor>`
|
||||||
chapter.
|
chapter.
|
||||||
It includes the explanation regarding the fact you will be prompted to type your username and password,
|
It includes the explanation regarding the fact you will be prompted to type your username and
|
||||||
and what to do if you use the two-factor authentication.
|
password, and what to do if you use the two-factor authentication.
|
||||||
|
|
||||||
Or, from your computer terminal:
|
Or, from your computer terminal:
|
||||||
|
|
||||||
@ -217,7 +217,8 @@ Once the database ready, you can access it by clicking the *Connect* button.
|
|||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
If your Odoo.sh project is configured to install your module automatically,
|
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.
|
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:
|
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
|
.. image:: first_module/firstmodule-test-devtostaging.png
|
||||||
:align: center
|
:align: center
|
||||||
@ -244,8 +246,8 @@ You can either:
|
|||||||
|
|
||||||
You can also use the :code:`git merge` command to merge your branches.
|
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
|
This will create a new staging build, which will duplicate the production database and make it run
|
||||||
updated with your latest changes of your branch.
|
using a server updated with your latest changes of your branch.
|
||||||
|
|
||||||
.. image:: first_module/firstmodule-test-mergedinstaging.png
|
.. image:: first_module/firstmodule-test-mergedinstaging.png
|
||||||
:align: center
|
:align: center
|
||||||
@ -257,11 +259,13 @@ Once the database ready, you can access it using the *Connect* button.
|
|||||||
Install your module
|
Install your module
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Your module will not be installed automatically, you have to install it from the apps menu.
|
Your module will not be installed automatically, you have to install it from the apps menu. Indeed,
|
||||||
Indeed, the purpose of the staging build is to test the behavior of your changes as it would be on your production,
|
the purpose of the staging build is to test the behavior of your changes as it would be on your
|
||||||
and on your production you would not like your module to be installed automatically, but on demand.
|
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>`
|
* Activate the :ref:`developer mode <developer-mode>`
|
||||||
* in the apps menu, click the *Update Apps List* button,
|
* 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
|
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,
|
From the Odoo.sh editor,
|
||||||
* browse to your module folder *~/src/user/my_module*,
|
* browse to your module folder *~/src/user/my_module*,
|
||||||
* then, open the file *models/models.py*.
|
* then, open the file *models/models.py*.
|
||||||
|
|
||||||
Or, from your computer,
|
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,
|
* then, open the file *models/models.py* using the editor of your choice,
|
||||||
such as *Atom*, *Sublime Text*, *PyCharm*, *vim*, ...
|
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,
|
In order to be applied in existing databases, such as your production database,
|
||||||
these changes requires the module to be updated.
|
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,
|
If you would like the update to be performed automatically by the Odoo.sh platform when you push
|
||||||
increase your module version in its manifest.
|
your changes, increase your module version in its manifest.
|
||||||
|
|
||||||
Open the module manifest *__manifest__.py*.
|
Open the module manifest *__manifest__.py*.
|
||||||
|
|
||||||
@ -367,7 +373,8 @@ with
|
|||||||
|
|
||||||
'version': '0.2',
|
'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.
|
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
|
.. image:: first_module/firstmodule-test-addachange-build.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
||||||
Once you tested your changes, you can merge your changes in the production branch, for instance by drag-and-dropping the
|
Once you tested your changes, you can merge your changes in the production branch, for instance by
|
||||||
branch on the production branch in the Odoo.sh interface. As you increased the module version in the manifest,
|
drag-and-dropping the branch on the production branch in the Odoo.sh interface. As you increased the
|
||||||
the platform will update the module automatically and your new field will be directly available.
|
module version in the manifest, the platform will update the module automatically and your new field
|
||||||
Otherwise you can manually update the module within the apps list.
|
will be directly available. Otherwise you can manually update the module within the apps list.
|
||||||
|
|
||||||
Use an external Python library
|
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,
|
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.
|
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 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
|
The feature is explained in this section by using the `Unidecode library
|
||||||
your module.
|
<https://pypi.python.org/pypi/Unidecode>`_ in your module.
|
||||||
|
|
||||||
Create a file *requirements.txt* in the root folder of your repository
|
Create a file *requirements.txt* in the root folder of your repository
|
||||||
|
|
||||||
@ -442,8 +457,8 @@ Add
|
|||||||
|
|
||||||
unidecode
|
unidecode
|
||||||
|
|
||||||
Then use the library in your module, for instance to remove accents from characters in the name field of your
|
Then use the library in your module, for instance to remove accents from characters in the name
|
||||||
model.
|
field of your model.
|
||||||
|
|
||||||
Open the file *models/models.py*.
|
Open the file *models/models.py*.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user