Compare commits

...

9 Commits

Author SHA1 Message Date
Denis Ledoux
3218d318fe [FIX] maintain: upgrade command line link
closes odoo/documentation#1150

X-original-commit: 7276929071
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2021-09-22 10:37:59 +00:00
Tiffany Chang (tic)
bb3996b936 [IMP] developer/{howtos,reference}: update training to match v15 changes
- Reference v15 training solutions
- Refer to Command namespace instead of triplets (e.g.
  Command.create(values) instead of (0, 0, values)
- Add notice about OWL transition
- Add reference to @api.ondelete (instead of override unlink())
- Remove references to SavepointCase (now only TransactionCase) from
  unit test topic

- Also add missing reference documentation for ondelete

closes odoo/documentation#1146

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-09-20 11:47:42 +00:00
Tiffany Chang (tic)
b3845ae0d8 [IMP] developer/howtos: proofread adv topics
- Cleaned up the language a tiny bit
- Fixed small errors/typos
- Add some missing info for dashboard topic
- Updated unit test exercise to match what's in the solutions repo

Part-of: odoo/documentation#1146
2021-09-20 11:47:42 +00:00
Tiffany Chang (tic)
85410bd8dc [IMP] developer/howtos: encourage linters more
There have been complaints of newbies not setting up their linters
therefore let's emphasize their use/setup more in the tutorial and hope
for the best.

Part-of: odoo/documentation#1146
2021-09-20 11:47:42 +00:00
Jonathan Castillo (jcs)
248135a48e [IMP] maintain: update test doc link in versions upgrade
closes odoo/documentation#1141

X-original-commit: 0842b682fc
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-09-14 16:23:07 +00:00
Raf Geens
6833379ad3 [FIX] app/accounting: Fix outdated Colombian test server url
The test server url for Carvajal T&S was out of date and has been
updated with the correct one. Carvajal has also split into 2
different companies, with new customers using the new company (CSC)
by default but the older company (CTS) still being available for
existing customers. See task 2508208. So the documentation was
updated to include both of them.

CTS (Carvajal T&S) was being used to refer to Carvajal in general,
so to avoid confusion those mentions have been changed to just
"Carvajal" since it can refer to either CTS or CSC.

closes odoo/documentation#1138

X-original-commit: 396df2abdd
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-09-14 16:18:51 +00:00
Jonathan Castillo (jcs)
00046cb690 [FIX] subscriptions: wrong Odoo Tutorials link
task-2636416

closes odoo/documentation#1136

X-original-commit: ebf216cc8e
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-09-14 12:31:13 +00:00
Antoine Vandevenne (anv)
ac40d2008c [IMP] conf: hide saas branches from the version switcher 2021-09-09 17:22:27 +02:00
Antoine Vandevenne (anv)
5cef86f181 [REL] freeze saas-14.5 branch 2021-09-09 16:25:46 +02:00
21 changed files with 204 additions and 149 deletions

View File

@ -24,7 +24,7 @@ SOURCE_DIR = content
HTML_BUILD_DIR = $(BUILD_DIR)/html
ifdef VERSIONS
HTML_BUILD_DIR := $(HTML_BUILD_DIR)/master
HTML_BUILD_DIR := $(HTML_BUILD_DIR)/saas-14.5
endif
ifneq ($(CURRENT_LANG),en)
HTML_BUILD_DIR := $(HTML_BUILD_DIR)/$(CURRENT_LANG)

View File

@ -4,11 +4,11 @@
### Requirements
- [Git](https://www.odoo.com/documentation/master/contributing/documentation.html#install-git)
- [Python 3.6, 3.7, or 3.8](https://www.odoo.com/documentation/master/contributing/documentation.html#python)
- Python dependencies listed in the file [`requirements.txt`](https://github.com/odoo/documentation/tree/master/requirements.txt).
- [Make](https://www.odoo.com/documentation/master/contributing/documentation.html#make)
- A local copy of the [odoo/odoo repository in master](https://github.com/odoo/odoo/tree/master) (Optional)
- [Git](https://www.odoo.com/documentation/15.0/contributing/documentation.html#install-git)
- [Python 3.6, 3.7, or 3.8](https://www.odoo.com/documentation/15.0/contributing/documentation.html#python)
- Python dependencies listed in the file [`requirements.txt`](https://github.com/odoo/documentation/tree/15.0/requirements.txt).
- [Make](https://www.odoo.com/documentation/15.0/contributing/documentation.html#make)
- A local copy of the [odoo/odoo repository in 15.0](https://github.com/odoo/odoo/tree/15.0) (Optional)
### Instructions
@ -23,7 +23,7 @@
2. Open the file `documentation/_build/html/index.html` in your web browser to display the render.
3. See [this guide](https://www.odoo.com/documentation/master/contributing/documentation.html#preview-your-changes)
3. See [this guide](https://www.odoo.com/documentation/15.0/contributing/documentation.html#preview-your-changes)
for more detailed instructions.
Optional: to fully build the developer documentation with inline docstrings for documented Python
@ -34,7 +34,7 @@ be shown.
## Contribute to the documentation
For contributions to the content of the documentation, please refer to the
[Introduction Guide](https://www.odoo.com/documentation/master/contributing/documentation.html).
[Introduction Guide](https://www.odoo.com/documentation/15.0/contributing/documentation.html).
To **report a content issue**, **request new content** or **ask a question**, use the
[repository's issue tracker](https://github.com/odoo/documentation-user/issues) as usual.

13
conf.py
View File

@ -19,7 +19,7 @@ copyright = 'Odoo S.A.'
# `version` if the version info for the project being documented, acts as replacement for |version|,
# also used in various other places throughout the built documents.
# `release` is the full version, including alpha/beta/rc tags. Acts as replacement for |release|.
version = release = 'master'
version = release = 'saas-14.5'
# The minimal Sphinx version required to build the documentation.
needs_sphinx = '3.0.0'
@ -70,19 +70,20 @@ if not odoo_dir.is_dir():
f"Could not find Odoo sources directory at {odoo_dir.absolute()}.\n"
f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
f"In order to fully build the 'Developer' documentation, clone the repository with "
f"`git clone https://github.com/odoo/odoo` or create a symbolink link."
f"`git clone https://github.com/odoo/odoo` or create a symbolic link."
)
else:
sys.path.insert(0, str(odoo_dir.absolute()))
from odoo import release as odoo_release # Don't collide with Sphinx's 'release' config option
odoo_version = odoo_release.version if 'alpha' not in odoo_release.version else 'master'
odoo_version = odoo_release.version.replace('~', '-') \
if 'alpha' not in odoo_release.version else 'master'
if release != odoo_version:
_logger.warning(
f"Found Odoo sources directory but with version '{odoo_version}' incompatible with "
f"documentation version '{version}'.\n"
f"The 'Developer' documentation will be built but autodoc directives will be skipped.\n"
f"In order to fully build the 'Developer' documentation, checkout the matching branch"
f" with `cd odoo && git checkout {version}`."
f"In order to fully build the 'Developer' documentation, checkout the matching branch "
f"with `cd odoo && git checkout {version}`."
)
else:
_logger.info(f"Found Odoo sources directory matching documentation version {release}.")
@ -290,7 +291,7 @@ def _generate_alternate_urls(app, pagename, templatename, context, doctree):
for _alternate_version in sorted(_alternate_versions, reverse=True)
if _alternate_version != version and (
_alternate_version != 'master' or pagename.startswith('developer')
)
) and not _alternate_version.startswith('saas')
]
def _localize():

View File

@ -128,7 +128,7 @@ There are two possibilities:
#. Via the interface of our `website form <https://upgrade.odoo.com>`_
#. | For technically-advanced users and partners, via the following command line (to be used on the
machine where your database is hosted):
| ``python <(curl -s beta.upgrade.odoo.com/upgrade) test -d <your db name> -t 14.0``
| ``python <(curl -s https://upgrade.odoo.com/upgrade) test -d <your db name> -t 14.0``
What does it do?
~~~~~~~~~~~~~~~~
@ -190,8 +190,8 @@ Test guidance
Every business and organization has its own operational needs and will have to test its specific
Odoo instance respectively. However, we recommend you look at `the test scenario
<https://drive.google.com/open?id=1Lm4JqbsHBirB1wMi14UChoz_YHLjx5ec>`_ we created, a high-level idea
of what you should test and look out for.
<https://docs.google.com/document/d/1ypNs7JKPOsjNbKpdiKFH7Al6g6whZ9jr7f7duAQ5E1w/>`_ we created, a
high-level idea of what you should test and look out for.
.. todo:: change link "test scenario" once the related doc is published

View File

@ -19,7 +19,7 @@ requires the next modules:
contains the default setup for: chart of accounts, taxes,
retentions, identification document types
#. **l10n_co_edi**: This module includes all the extra fields that are
required for the Integration with Carvajal T&S and generate the
required for the Integration with Carvajal and generate the
electronic invoice, based on the DIAN legal requirements.
@ -43,12 +43,12 @@ filter and search for "Colombia". Then click on *Install* for the first two modu
:align: center
Configure credentials for Carvajal T&S web service
--------------------------------------------------
Configure credentials for Carvajal web service
----------------------------------------------
Once that the modules are installed, in order to be able to connect
with Carvajal T&S Web Service, it's necessary to configure the user
and credentials, this information will be provided by Carvajal T&S.
with Carvajal Web Service, it's necessary to configure the user
and credentials, this information will be provided by Carvajal.
Go to :menuselection:`Accounting --> Configuration --> Settings` and
look for the *Colombian Electronic Invoice* section.
@ -56,12 +56,20 @@ look for the *Colombian Electronic Invoice* section.
.. image:: media/colombia03.png
:align: center
Using the Testing mode it is possible to connect with a Carvajal T&S
Using the Testing mode it is possible to connect with a Carvajal
testing environment. This allows users to test the complete workflow
and integration with the CEN Financiero portal, which is accessible
here: https://cenfinancierolab.cen.biz
here:
Once that Odoo and Carvajal T&S is fully configured and ready for
CTS (Carvajal T&S)
https://cenflab.cen.biz/site/
CSC (Carvajal Servicios de Comunicación)
https://web-stage.facturacarvajal.com/
CSC is the default for new databases.
Once that Odoo and Carvajal are fully configured and ready for
production the testing environment can be disabled.

View File

@ -18,7 +18,7 @@ requiere los siguientes Módulos:
- Tipos de Documentos de Identificación
#. **l10n_co_edi**: Este módulo incluye todos los campos adicionales que son
requeridos para la Integración entre Carvajal T&S y la generación de la
requeridos para la Integración entre Carvajal y la generación de la
Factura Electrónica, basado en los requisitos legales de la DIAN.
@ -42,12 +42,12 @@ Instalar a los primeros dos módulos:
:align: center
Configuración de las credenciales del Servicio Web de Carvajal T&S
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Configuración de las credenciales del Servicio Web de Carvajal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Una vez que los módulos están instalados, para poderte conectar con el
Servicio Web de Carvajal T&S, es necesario configurar el Usuario y las
Credenciales. Esta información será provista por Carvajal T&S.
Servicio Web de Carvajal, es necesario configurar el Usuario y las
Credenciales. Esta información será provista por Carvajal.
| Ve a :menuselection:`Facturación --> Configuración --> Configuración` y busca la sección
**Facturación Electrónica Colombiana**
@ -55,14 +55,21 @@ Configuración de las credenciales del Servicio Web de Carvajal T&S
:align: center
La funcionalidad de pruebas le permite conectarse e interactuar con el
ambiente piloto de Carvajal T&S, esto permite a los usuarios probar el
ambiente piloto de Carvajal, esto permite a los usuarios probar el
flujo completo y la integración con el Portal Financiero CEN, al cual
se accede a través de la siguiente liga: `Cenfinanciero <https://cenfinancierolab.cen.biz>`_.
se accede a través de la siguiente liga:
CTS (Carvajal T&S)
https://cenflab.cen.biz/site/
CSC (Carvajal Servicios de Comunicación)
https://web-stage.facturacarvajal.com/
CSC es el predeterminado para nuevas bases de datos.
Una vez que el ambiente de producción está listo en Odoo y en Carvajal
T&S el ambiente de pruebas debe ser deshabilitado para poder enviar la
información al ambiente de producción de Carvajal, para el cual es
utilizada la siguiente URL: `Cenfinanciero <https://cenfinancierolab.cen.biz>`_.
el ambiente de pruebas debe ser deshabilitado para poder enviar la
información al ambiente de producción de Carvajal.
Configuración de Información para PDF

View File

@ -12,7 +12,7 @@ keep the churn under control and have reporting on the main KPIs: MRR, ARR, rete
upselling, etc.
.. seealso::
- `Odoo Tutorials: Subscriptions <https://www.odoo.com/slides/subscription-28>`_
- `Odoo Tutorials: Subscriptions <https://www.odoo.com/slides/subscription-20>`_
.. toctree::
:titlesonly:

View File

@ -224,7 +224,7 @@ Python comes with its own package manager: `pip
a single command.
#. Download and install the recommended release (`see README file
<https://github.com/odoo/documentation/tree/master/README.md>`_) of **Python 3** on your machine.
<https://github.com/odoo/documentation/tree/15.0/README.md>`_) of **Python 3** on your machine.
#. Make sure to have **pip** installed on your machine (on Windows, you can install pip alongside
Python).
#. Execute the following commands in a terminal to verify that both installations finished

View File

@ -36,8 +36,8 @@ A reference to the rendered :file:`prices.html` and :file:`variants.html` could
#. Absolute:
- ``https://odoo.com/documentation/master/applications/sales/sales/products_prices/prices.html``
- ``https://odoo.com/documentation/master/applications/sales/sales/products_prices/products/variants.html``
- ``https://odoo.com/documentation/15.0/applications/sales/sales/products_prices/prices.html``
- ``https://odoo.com/documentation/15.0/applications/sales/sales/products_prices/products/variants.html``
#. Relative:

View File

@ -29,6 +29,12 @@ on your background.
For reference this is the official `Python tutorial`_.
.. note::
Since version 15.0, Odoo is actively transitioning to using its own in-house developed `OWL
framework <https://odoo.github.io/owl/>`_ as part of its presentation tier. The legacy JavaScript
framework is still supported but will be depreciated over time. This will be discussed further in
advanced topics.
Odoo modules
============

View File

@ -337,6 +337,18 @@ For Python, we use PEP8 with these options ignored:
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 <https://code.visualstudio.com/docs/python/linting>`_. There are multiple
linter options you are free to choose from, but `Flake8 <https://pypi.org/project/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/

View File

@ -71,6 +71,12 @@ The decorator :func:`~odoo.api.model` is necessary for the :meth:`~odoo.models.M
method because the content of the recordset ``self`` is not relevant in the context of creation,
but it is not necessary for the other CRUD methods.
It is also important to note that even though we can directly override the
:meth:`~odoo.models.Model.unlink` method, you will almost always want to write a new method with
the decorator :func:`~odoo.api.ondelete` instead. Methods marked with this decorator will be
called during :meth:`~odoo.models.Model.unlink` and avoids some issues that can occur during
uninstalling the model's module when :meth:`~odoo.models.Model.unlink` is directly overridden.
In Python 3, ``super()`` is equivalent to ``super(TestModel, self)``. The latter may be necessary
when you need to call the parent method with a modified recordset.
@ -85,8 +91,8 @@ when you need to call the parent method with a modified recordset.
- Prevent deletion of a property if its state is not 'New' or 'Canceled'
Tip: override :meth:`~odoo.models.Model.unlink` and remember that ``self`` can be a recordset
with more than one record.
Tip: create a new method with the :func:`~odoo.api.ondelete` decorator and remember that
``self`` can be a recordset with more than one record.
- At offer creation, set the property state to 'Offer Received'. Also raise an error if the user
tries to create an offer with a lower amount than an existing offer.

View File

@ -133,24 +133,24 @@ information:
Moreover, an invoice line needs to be linked to an invoice. The easiest and most efficient way
to link a line to an invoice is to include all lines at invoice creation. To do this, the
``invoice_line_ids`` field is included in the ``account.move`` creation, which is a
:class:`~odoo.fields.One2many`. One2many and Many2many use special 'commands' described in
:ref:`reference/orm/models/crud`. This format is a list of triplets executed sequentially, where
each triplet is a command to execute on the set of records. Here is a simple example to include
a One2many field ``line_ids`` at creation of a ``test.model``::
:class:`~odoo.fields.One2many`. One2many and Many2many use special 'commands' which have been
made human readable with the :class:`~odoo.fields.Command` namespace. This namespace represents
a triplet command to execute on a set of records. The triplet was originally the only option to
do these commands, but it is now standard to use the namespace instead. The format is to place
them in a list which is executed sequentially. Here is a simple example to include a One2many
field ``line_ids`` at creation of a ``test.model``::
from odoo import Command
def inherited_action(self):
self.env["test.model"].create(
{
"name": "Test",
"line_ids": [
(
0,
0,
{
"field_1": "value_1",
"field_2": "value_2",
},
)
Command.create({
"field_1": "value_1",
"field_2": "value_2",
})
],
}
)

View File

@ -18,9 +18,9 @@ to improve the quality of the Odoo Apps code.
.. exercise:: Polish your code.
Refactor your code to respect the coding guidelines. Don't forget to respect the module
structure, the variable names, the method name convention, the model attribute order and the
xml ids.
Refactor your code to respect the coding guidelines. Don't forget to run your linter and
respect the module structure, the variable names, the method name convention, the model
attribute order and the xml ids.
Your first Pull Request (PR)
============================

View File

@ -10,8 +10,9 @@ Advanced B: ACL and Record Rules
<howto/rdtraining>`.
To follow the exercise, it is recommended that you fetch the branch
14.0-core from the repository XXX, it
contains a version of the module created during the core training we can use
15.0-core from the
`technical training solutions <https://github.com/odoo/technical-training-solutions/tree/15.0-core>`__ repository.
It contains a version of the module created during the core training we can use
as a starting point.
So far we have mostly concerned ourselves with implementing useful features.
@ -33,7 +34,7 @@ However:
* Real-estate agents don't need or get to decide what property types or tags are
*available*.
* Real-estate agents can have *exclusive* properties, we do not want one agent
to be able to manage another's exclusivities.
to be able to manage another's exclusives.
* All real-estate agents should be able to confirm the sale of a property they
can manage, but we do not want them to be able to validate or mark as paid
any invoice in the system.
@ -44,7 +45,7 @@ However:
Because it's easier for users to disable unnecessary security rules than it
is to create them from nothing, it's better to err on the side of caution
and limiting access: users can relax that access if necessary or convenient.
and limit access: users can relax that access if necessary or convenient.
Groups
======
@ -223,7 +224,7 @@ individual records:
<field name="name">A description of the rule's role</field>
<field name="model_id" ref="model_to_manage"/>
<field name="perm_read" eval="False"/>
<field name="groups" eval="[(4, ref('base.group_user'))]"/>
<field name="groups" eval="[Command.link(ref('base.group_user'))]"/>
<field name="domain_force">[
'|', ('user_id', '=', user.id),
('user_id', '=', False)
@ -294,7 +295,7 @@ do so.
There are two main ways to bypass existing security checks in Odoo, either
wilfully or as a side-effect:
* The ``sudo()`` method will create a new recorset in "sudo mode", this ignores
* The ``sudo()`` method will create a new recordset in "sudo mode", this ignores
all access rules and access rights (although hard-coded group and user checks
may still apply).
* Performing raw SQL queries will bypass access rules and access rights as a
@ -366,9 +367,9 @@ Explicit security checks can be performed by:
specific models or records.
* Checking that the current user has specific groups hard-coded to allow or deny
an operation (``self.env.user.has_group``).
* Calling the ``check_access_rights(operation)`` method on a recorset, this
* Calling the ``check_access_rights(operation)`` method on a recordset, this
verifies whether the current user has access to the model itself.
* Calling ``check_access_rule(operations)`` on a non-empty recorset, this
* Calling ``check_access_rule(operations)`` on a non-empty recordset, this
verifies that the current user is allowed to perform the operation on *every*
record of the set.
@ -380,7 +381,7 @@ Explicit security checks can be performed by:
Before creating the invoice, use ``check_access_rights`` and
``check_access_rule`` to ensure that the current user can update properties
in general, and this specific property in particular.
in general as well as the specific property the invoice is for.
Re-run the bypass script, check that the error occurs before the print.
@ -393,7 +394,7 @@ Multi-company security
:ref:`reference/howtos/company` for an overview of multi-company facilities
in general, and :ref:`multi-company security rules <howto/company/security>`
this in particular.
in particular.
Documentation on rules in general can, again, be found at
:ref:`reference/security/rules`.
@ -403,15 +404,15 @@ Multi-company security
At the end of this section, agents should only have access to properties
of their agency (or agencies).
For one reason or an other we might need to manage our real-estate business
as multiple companies e.g. we might have largely autonomous agencies, or a
For one reason or another we might need to manage our real-estate business
as multiple companies e.g. we might have largely autonomous agencies, a
franchise setup, or multiple brands (possibly from having acquired other
real-estate businesses) which remain legally or financially separate from one
another.
Odoo can be used to manage multiple companies inside the same system, however
the actual handling is up to individual modules: Odoo itself provides the tools
to manage the issue like company-dependent fields and *multi-company rules*,
to manage the issue of company-dependent fields and *multi-company rules*,
which is what we're going to concern ourselves with.
We want different agencies to be "siloed" from one another, with properties
@ -447,7 +448,7 @@ associated with *one* of the companies the user has access to:
Multi-company rules are usually :ref:`global <reference/security/rules/global>`,
otherwise there is a high risk that additional rules would allow bypassing
the muti-company rules.
the multi-company rules.
.. exercise::
@ -472,7 +473,7 @@ Visibility != security
.. admonition:: **Goal**
At the end of this section, real-estate agents should not see the Settings
menu of the rea-estate application, but should still be able to set the
menu of the real-estate application, but should still be able to set the
property type or tags.
Specific Odoo models can be associated directly with groups (or companies, or
@ -480,7 +481,7 @@ users). It is important to figure out whether this association is a *security*
or a *visibility* feature before using it:
* *Visibility* features mean a user can still access the model or record
otherwise, either through an other part of the interface or by :doc:`perform
otherwise, either through another part of the interface or by :doc:`performing
operations remotely using RPC <../../misc/api/odoo>`, things might just not be
visible in the web interface in some contexts.
* *Security* features mean a user can not access records, fields or operations.
@ -507,10 +508,10 @@ Here are some examples:
.. exercise::
Real Estate agents can not add property types or tags, and can see their
Real Estate agents can not add property types or tags, but can see their
options from the Property form view when creating it.
The Settings menu just adds noise to their interface, it should only be
The Settings menu just adds noise to their interface, make it only
visible to managers.
Despite not having access to the Property Types and Property Tags menus anymore,

View File

@ -6,7 +6,8 @@ Advanced C: Master and Demo Data
.. tip:: This tutorial assumes you followed the Core Training.
To do the exercise, fetch the branch 14.0-core from the repository XXX.
To do the exercise, fetch the branch 15.0-core from the
`technical training solutions <https://github.com/odoo/technical-training-solutions/tree/15.0-core>`__ repository.
It contains a basic module we will use as a starting point
Data Types
@ -23,23 +24,23 @@ We already met technical data previously since we have defined
:ref:`security rules<howto/rdtraining/N_security>`, :ref:`views<reference/views>` and
:ref:`actions<reference/actions>`. Those are one kind of master data.
On top of technical data, business data can be defined: countries, currencies, units of measure but
also complete country localization (legal reports, tax definitions, chart of account), and much
On top of technical data, business data can be defined, e.g. countries, currencies, units of measure,
as well as complete country localization (legal reports, tax definitions, chart of account), and much
more...
Demo Data
---------
Next to master data which are requirements for the modules to work properly, we also like having
data for demonstration purpose setups:
In additional to master data, which are requirements for a module to work properly, we also like
having data for demonstration purposes:
* Help the sales representatives to make their demos quickly.
* Have a set of working data for developers to test the new features and see what it looks like
with something they might not have created without it.
* Help the sales representatives make their demos quickly.
* Have a set of working data for developers to test new features and see how these new features look
with data they might not have added themselves.
* Test that the data is loaded correctly, without raising an error.
* Be ready to use most of the features quickly when creating a new database.
* Setup most of the features to be used quickly when creating a new database.
Demo data is automatically loaded when you start the server if you didn't say explicitly you don't
Demo data is automatically loaded when you start the server if you don't explicitly say you don't
want it. This can be done in the database manager or with the command line.
.. code-block:: console
@ -70,15 +71,15 @@ Manifest
**Reference**: the documentation related to this topic can be found in
:ref:`Module Manifests<reference/module/manifest>`.
The data is declared either in CSV either in XML.
Data is declared either in CSV or in XML.
Each file containing data must be added in the manifest for them to be loaded.
The keys to use in the manifest to add new data are ``data`` for the master data and ``demo`` for
the demo data. Both values should be a list of strings representing the relative path to the files
the demo data. Both values should be a list of strings representing the relative paths to the files
declaring the data.
Usually, the demo data is set in a ``demo`` folder, the views and actions are put in a ``views``
folder, the security related data is put in a ``security`` folder, and the other data is set in a
Usually, demo data is in a ``demo`` folder, views and actions are in a ``views``
folder, security related data is in a ``security`` folder, and other data is in a
``data`` folder.
If your work tree looks like this:
@ -129,7 +130,7 @@ CSV
:ref:`CSV data files<reference/data/csvdatafiles>`.
The easiest way to declare simple data is by using the CSV format. This is however limited in terms
of features: use it for long lists of simple models, but prefer XML in the other cases.
of features: use it for long lists of simple models, but prefer XML otherwise.
.. code-block:: text
@ -153,7 +154,7 @@ XML
**Reference**: the documentation related to this topic can be found in
:ref:`Data Files<reference/data>`.
When the data to create is a bit more complex it can be useful, or even needed, to do it in XML.
When the data to create is more complex it can be useful, or even necessary, to do it in XML.
.. code-block:: xml
@ -243,7 +244,7 @@ works too if you are in the module declaring it).
Deco Addict Big Villa 1500001 14
============== ========= ======= ========
.. exercise:: Both properties should be Residential properties.
.. exercise:: Ensure both of your demo properties are created with their Property Type set to Residential.
``eval``
~~~~~~~~
@ -279,13 +280,13 @@ Sometimes, you need to call the ORM to do a ``search``. This is not feasible wit
</record>
</odoo>
In this code snippet, it is needed because the master data actually depends on the localization
In this code snippet, it is needed because the master data depends on the localization
installed.
``function``
~~~~~~~~~~~~
You might also need to execute python code when loading the data.
You might also need to execute python code when loading data.
.. code-block:: xml
@ -303,36 +304,29 @@ Add X2many fields
-----------------
**Reference**: the documentation related to this topic can be found in
:ref:`Common ORM methods<reference/orm/models/crud>`.
:class:`~odoo.fields.Command`.
If you need to add related data in a One2many or a Many2many field, you can do so by using the
common ORM methods.
:class:`~odoo.fields.Command` methods.
.. code-block:: xml
<odoo>
<record id="id1" model="tutorial.example">
<field name="related_ids" eval="[
(0, 0, {
Command.create({
'name': 'My name',
}),
(0, 0, {
Command.create({
'name': 'Your name',
}),
(4, ref('model.xml_id')),
Command.link(ref('model.xml_id')),
]"/>
</record>
</odoo>
.. code-block:: text
id,parent_id:id,name
"child1","module.parent","Name1"
"child2","module.parent","Name2"
"child3","module.parent","Name3"
.. exercise:: Create one new Property, but this time with some offers created directly inside the
One2many field linking to the Offers.
One2many field linked to the Offers.
Accessing the data
==================

View File

@ -6,7 +6,8 @@ Advanced E: Python Unit Tests
.. tip:: This tutorial assumes you followed the Core Training.
To do the exercise, fetch the branch 14.0-core from the repository XXX.
To do the exercise, fetch the branch 15.0-core from the
`technical training solutions <https://github.com/odoo/technical-training-solutions/tree/15.0-core>`__ repository.
It contains a basic module we will use as a starting point
**Reference**:
@ -15,11 +16,11 @@ Advanced E: Python Unit Tests
Writing tests is a necessity for multiple reasons. Here is a non exhaustive list:
* Ensure it will not be broken in the future
* Ensure code will not be broken in the future
* Define the scope of your code
* Give examples of use cases
* It is one way to technically document the code
* Help you develop by defining your goal before working towards it
* Help your coding by defining your goal before working towards it
Running Tests
=============
@ -79,7 +80,7 @@ Integration Bots
================
.. note:: This section is only for Odoo employees and people that are contributing to
`github.com/odoo`. We highly recommend having your own CI if it is not the case.
`github.com/odoo`. We highly recommend having your own CI otherwise.
When a test is written, it is important to make sure it always passes when modifications are
applied to the source code. To automate this task, we use a development practice called
@ -100,7 +101,7 @@ GitHub.
You can see the state of a commit/branch by filtering on the runbot dashboard.
A **bundle** is created for each branch. A bundle consists of a configuration and contains the
A **bundle** is created for each branch. A bundle consists of a configuration and
batches.
A **batch** is a set of builds, depending on the parameters of the bundle.
@ -116,17 +117,17 @@ process. Generally it is used to split the post install tests in 4 parallel inst
A sub-build is green if all the tests are passing and there are no errors/warnings logged.
.. note::
* All tests are run whatever the modifications done. Correcting a typo in an error message or
refactoring a whole module triggers the same tests. It will install all the modules. This means
something might not work if Runbot green but your changes depend on something you don't depend
on.
* All tests are run regardless of the modifications done. Correcting a typo in an error message or
refactoring a whole module triggers the same tests. All modules will be installed as well. This means
something might not work even if the Runbot is green, i.e. your changes depend on a module that the
module the changes are in doesn't depend on.
* The localization modules (i.e. country-specific modules) are not installed on Runbot (except
the generic one), some modules with external dependencies can be excluded also.
* There is a nightly build running additional tests, like module operations, localization, single
the generic one). Some modules with external dependencies can also be excluded.
* There is a nightly build running additional tests: module operations, localization, single
module installs, multi-builds for nondeterministic bugs, etc.
These are not kept in the standard CI to shorten the time of execution.
You can also login on a build built by Runbot. There are 3 users usable: `admin`, `demo` and
You can also login to a build built by Runbot. There are 3 users usable: `admin`, `demo` and
`portal`. The password is the same as the login. This is useful to quickly test things on different
versions without having to build it locally. The full logs are also available; these are used for
monitoring.
@ -138,9 +139,9 @@ You will most likely have to gain a little bit more experience before having the
robodoo, but here are a few remarks anyways.
Robodoo is the guy spamming the CI status as tags on your PRs, but he is also the guy that kindly
integrates your commits on the main repositories.
integrates your commits into the main repositories.
When the last batch is green, the reviewer can ask robodoo to merge your PR (actually it is more
When the last batch is green, the reviewer can ask robodoo to merge your PR (it is more
a `rebase` than a `merge`). It will then go to the mergebot.
Mergebot
@ -166,8 +167,8 @@ your branch on the target and rerun the tests locally.
Modules
=======
Because Odoo is modular, the tests need to be modular also. This means the modules are defined in
the module that adds the functionality you add; and that tests cannot depend on functionality
Because Odoo is modular, the tests need to be also modular. This means tests are defined in
the module that adds the functionality you are adding in and tests cannot depend on functionality
coming from modules your module doesn't depend on.
**Reference**: the documentation related to this topic can be found in
@ -175,25 +176,25 @@ coming from modules your module doesn't depend on.
.. code-block:: python
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase
from odoo.tests import tagged
# The CI will run these tests after all the modules are installed,
# not right after installing the one defining it.
@tagged('post_install', '-at_install') # add `post_install` and remove `at_install`
class PostInstallTestCase(SavepointCase):
class PostInstallTestCase(TransactionCase):
def test_01(self):
...
@tagged('at_install') # this is the default
class AtInstallTestCase(SavepointCase):
class AtInstallTestCase(TransactionCase):
def test_01(self):
...
If the behavior you want to test can be changed by the installation of another module, you need to
ensure that the tag `at_install` is set; otherwise you can use the tag `post_install` to speed up
the CI, and ensure it is not changed if it shouldn't.
the CI and ensure it is not changed if it shouldn't.
Writing a test
==============
@ -233,27 +234,22 @@ import the test folder/module in the ``__init__.py`` of the module.
├── __init__.py
└── __manifest__.py
.. note:: Some older tests are extending ``odoo.tests.common.TransactionCase``, but they are less
scalable. The difference is that the setup is done per test method and not per test class.
The data changed are rollbacked between each test in `SavepointCase` to have the same behavior as
in `TransactionCase`.
All the tests should extend ``odoo.tests.common.SavepointCase``. You usually define a
``setUpClass``, and the tests. After doing the `setUpClass`, you have an `env` available on the
All the tests should extend ``odoo.tests.common.TransactionCase``. You usually define a
``setUpClass`` and the tests. After writing the `setUpClass`, you have an `env` available in the
class and can start interacting with the ORM.
These test classes are built on top of the ``unittest`` python module.
.. code-block:: python
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase
from odoo.exceptions import UserError
from odoo.tests import tagged
# The CI will run these tests after all the modules are installed,
# not right after installing the one defining it.
@tagged('post_install', '-at_install')
class EstateTestCase(SavepointCase):
class EstateTestCase(TransactionCase):
@classmethod
def setUpClass(cls):
@ -285,12 +281,18 @@ These test classes are built on top of the ``unittest`` python module.
with self.assertRaises(UserError):
self.properties.forbidden_action_on_sold_property()
.. note:: For more readability, split your tests into multiple files depending on the scope of the
tests. You can also have a Common class that most of the tests should inherit from; that common
.. note:: For better readability, split your tests into multiple files depending on the scope of the
tests. You can also have a Common class that most of the tests should inherit from; this common
class can define the whole set up for the module. For instance in
`account <https://github.com/odoo/odoo/blob/14.0/addons/account/tests/common.py>`__.
.. exercise:: Ensure no one can create an offer for a sold Property, and create a test for it.
.. exercise:: Update the code so no one can:
- Create an offer for a sold property
- Sell a property with no accepted offers on it
and create tests for both of these cases. Additionally check that selling a property that can
be sold is correctly marked as sold after selling it.
.. exercise:: Someone keeps breaking the reset of Garden Area and Orientation when you uncheck the

View File

@ -10,8 +10,9 @@ Advanced J: PDF Reports
and have installed :ref:`wkhtmltopdf <howto/rdtraining/02_setup/install-wkhtmltopdf>`.
To follow the exercise, it is recommended that you fetch the branch
14.0-core from the repository XXX, it
contains a version of the module created during the core training we can use
15.0-core from the
`technical training solutions <https://github.com/odoo/technical-training-solutions/tree/15.0-core>`__ repository.
It contains a version of the module created during the core training we can use
as a starting point.
We were previously :ref:`introduced to QWeb <howto/rdtraining/15_qwebintro>`
@ -95,9 +96,9 @@ If you don't have a set of data like this already, you can either:
* Complete :ref:`howto/rdtraining/C_data` (if you haven't done so already) and add the extra
cases to your demo data (you may need to create a new database to load in the demo data).
* Manually create the data in your database.
* Copy this `data file <https://github.com/odoo/technical-training-solutions/blob/14.0-J_reports/estate/data/estate_demo.xml>`__
* Copy this `data file <https://github.com/odoo/technical-training-solutions/blob/15.0-J_reports/estate/data/estate_demo.xml>`__
into a new directory (data) in your estate module and copy
`these lines <https://github.com/odoo/technical-training-solutions/blob/14.0-J_reports/estate/__manifest__.py#L21-L23>`__
`these lines <https://github.com/odoo/technical-training-solutions/blob/15.0-J_reports/estate/__manifest__.py#L21-L23>`__
into your __manifest__.py file (you may need to create a new database to load in the demo data).
Before continuing, click through your data in your database and make sure your data is as expected.

View File

@ -10,8 +10,9 @@ Advanced K: Dashboards
access to Odoo Enterprise features.
To follow the exercise, it is recommended that you fetch the branch
14.0-core from the repository XXX, it
contains a version of the module created during the core training we can use
15.0-core from the
`technical training solutions <https://github.com/odoo/technical-training-solutions/tree/15.0-core>`__ repository.
It contains a version of the module created during the core training we can use
as a starting point.
The term "Dashboard" is used in Odoo for objects that display data, but involves different
@ -118,9 +119,9 @@ If you don't have a set of data like this already, you can either:
* Complete :ref:`howto/rdtraining/C_data` (if you haven't done so already) and add the extra
cases to your demo data (you may need to create a new database to load in the demo data).
* Manually create the data in your database.
* Copy this `data file <https://github.com/odoo/technical-training-solutions/blob/14.0-K_dashboard/estate/data/estate_demo.xml>`__
* Copy this `data file <https://github.com/odoo/technical-training-solutions/blob/15.0-K_dashboard/estate/data/estate_demo.xml>`__
into a new directory called ``data`` in your estate module and copy
`these lines <https://github.com/odoo/technical-training-solutions/blob/14.0-K_dashboard/estate/__manifest__.py#L21-L23>`__
`these lines <https://github.com/odoo/technical-training-solutions/blob/15.0-K_dashboard/estate/__manifest__.py#L21-L23>`__
into your __manifest__.py file (you may need to create a new database to load in the demo data).
Click through your database data and make sure it is what you expect. Of course you can add the
@ -208,7 +209,7 @@ no xml id is provided for a graph or pivot view then the default view will be us
The cohort view will not work in the dashboard without a specific xml id. If you have already
created some of these views then you are welcome to add them to your dashboard! Sample graph and
pivot views are included in the
`solution code <https://github.com/odoo/technical-training-solutions/blob/14.0-K_dashboard/estate/views/estate_property_views.xml#L169-L191>`__
`solution code <https://github.com/odoo/technical-training-solutions/blob/15.0-K_dashboard/estate/views/estate_property_views.xml#L169-L191>`__
that you are welcome to use as well.
.. exercise:: Add subviews.
@ -319,7 +320,7 @@ View
Now that we have our model, we can make its dashboard view. There is no difference to how its made
except that its file is located in the ``report`` folder. Since it is a new model not linked to
any other model, we will also have to add a new menuitem to view our dashboard. Typically SQL views
are added under a first level menu called ``Reporting` (because it's a report, surprise!). Do you
are added under a first level menu called *Reporting* (because it's a report, surprise!). Do you
remember how to add a ``menuitem``? If not, revisit :ref:`howto/rdtraining/06_firstui`) again.
.. exercise:: Create report view.
@ -352,3 +353,17 @@ from this report.
**Tip 2** If you have a field that you do not want as a measure (i.e. in your pivot or
graph views), then you can add ``store=False`` to it and it will not show.
**Tip 3** If you have a SQL View that depends on context then instead of overriding
``BaseModel.init()`` set the ``_table_query`` property::
@property
def _table_query(self):
return 'SELECT %s FROM %s' % (self._select(), self._from())
The *select* and *from* methods remain the same.
`Here is an example <https://github.com/odoo/odoo/blob/14.0/addons/account/report/account_invoice_report.py>`__
of a report that depends on the currently selected companies (in a multi-company environment) context to
determine the currency exchange rates to use for accurately displaying amounts when the selected companies
have different currencies.

View File

@ -611,7 +611,7 @@ Method decorators
=================
.. automodule:: odoo.api
:members: depends, depends_context, constrains, onchange, returns, autovacuum, model, model_create_multi
:members: depends, depends_context, constrains, onchange, returns, autovacuum, model, model_create_multi, ondelete
.. .. currentmodule:: odoo.api

View File

@ -278,3 +278,5 @@ purchase/replenishment/flows/compute_date.rst applications/inventory_and_mrp/inv
purchase/replenishment/flows/purchase_triggering.rst applications/inventory_and_mrp/purchase/products/reordering.rst # (#814)
purchase/replenishment/flows/setup_stock_rule.rst applications/inventory_and_mrp/purchase/products/reordering.rst # (#814)
purchase/replenishment/multicompany/setup.rst applications/general/multi_companies/manage_multi_companies.rst # (#814)
# Redirections introduced in 15.0 :