[FIX] *: RST cleanup

RST cleanup to comply with the RST guidelines. This is required so we
can use "make test", as there are currently hundreds of errors. For now,
it is unusable because of the oldest code in this repo.

closes odoo/documentation#3568

Signed-off-by: Castillo Jonathan (jcs) <jcs@odoo.com>
This commit is contained in:
Jonathan Castillo (jcs)
2023-02-13 15:50:13 +00:00
parent 295d29effd
commit c5434ccd0a
65 changed files with 731 additions and 738 deletions
+23 -19
View File
@@ -1,8 +1,8 @@
:code-column:
===============
===========
Extract API
===============
===========
Odoo provides a service allowing you to automate the processing of your invoices. The service scans your document using an Optical
Character Recognition (OCR) engine and then uses AI-based algorithms to extract the fields of interest such as the total, the due date, or
@@ -15,6 +15,7 @@ allows you to integrate our service directly into your own projects.
Invoices
========
The extract API use the JSON-RPC2_ protocol. The diffent routes are located at the following address: **https://iap-extract.odoo.com**.
Expected successful flow
@@ -36,14 +37,15 @@ Routes
.. _webservices/extract_api/invoice_parse:
``/iap/invoice_extract/parse``
''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Description
^^^^^^^^^^^
***********
Request a processing of the document from the OCR. The route will return a `document_id` you can use to obtain the result of your request.
Request Body
^^^^^^^^^^^^
************
``jsonrpc`` (required)
Must be exactly “2.0”.
@@ -97,7 +99,7 @@ Request Body
}
Response
^^^^^^^^
********
``jsonrpc``
A string specifying the version of the JSON-RPC protocol. It will be “2.0”.
@@ -139,14 +141,15 @@ Response
.. _webservices/extract_api/invoice_get_results:
``/iap/invoice_extract/get_results``
''''''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Description
^^^^^^^^^^^
***********
Request the results of the documents ids obtained with the :ref:`/parse <webservices/extract_api/invoice_parse>` route. Can either return the results or a "request pending" message.
Request Body
^^^^^^^^^^^^
************
``jsonrpc`` (required)
|SAME_AS_PARSE|
@@ -174,7 +177,7 @@ Request Body
}
Response
^^^^^^^^
********
``jsonrpc``
|SAME_AS_PARSE|
@@ -231,7 +234,7 @@ Response
.. _webservices/extract_api/invoice_get_results/feature_result:
``feature_result``
''''''''''''''''''
~~~~~~~~~~~~~~~~~~
Each field of interest we want to extract from the invoice such as the total or the due date are also called features. An exhaustive list of all the extracted features can be found in the table below.
@@ -252,7 +255,7 @@ For each feature, we return a list of candidates and we spotlight the candidate
``candidate``
'''''''''''''
~~~~~~~~~~~~~
For each candidate we give its representation and position in the document. Candidates are sorted by decreasing order of suitability.
@@ -326,7 +329,7 @@ For each candidate we give its representation and position in the document. Cand
+-------------------------+------------------------------------------------------------------------------------+
``feature_result`` for the ``invoice_lines`` feature
''''''''''''''''''''''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It follows a more specific structure. It is basically a list of dictionaries where each dictionary represents an invoice line. Each value follows
a :ref:`webservices/extract_api/invoice_get_results/feature_result` structure.
@@ -353,15 +356,16 @@ a :ref:`webservices/extract_api/invoice_get_results/feature_result` structure.
.. _webservices/extract_api/invoice_validate:
``/iap/invoice_extract/validate``
'''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Description
^^^^^^^^^^^
***********
Route that validates the different features of an invoice. The validation step is an optional step but is strongly recommended. By telling the system if it were right or wrong for each
feature you give an important feedback. It has no direct impact but it helps the system to greatly improve its prediction accuracy for the invoices you will send in the future.
Request Body
^^^^^^^^^^^^
************
``jsonrpc`` (required)
|SAME_AS_PARSE|
@@ -395,7 +399,7 @@ Request Body
}
``validation``
''''''''''''''
~~~~~~~~~~~~~~
A **validation** for a given feature is a dictionary containing the textual representation of the expected value for this given feature.
This format apply for all the features except for ``global_taxes`` and ``invoice_lines`` which have more complex validation format.
@@ -406,7 +410,7 @@ This format apply for all the features except for ``global_taxes`` and ``invoice
{ "content": string|float }
validation for ``global_taxes``
'''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**content** is a list of dictionaries. Each dictionary represents a tax:
@@ -433,7 +437,7 @@ validation for ``global_taxes``
]}
validation for ``invoice_lines``
''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**lines** is a list of dictionaries. Each dictionary represents an invoice line. The dictionary keys speak for themselves.
+8 -11
View File
@@ -1,4 +1,3 @@
.. _reference/cmdline:
============================
@@ -371,7 +370,7 @@ Advanced Options
.. _reference/cmdline/dev:
Developer features
''''''''''''''''''
~~~~~~~~~~~~~~~~~~
.. option:: --dev <feature,feature,...,feature>
@@ -398,7 +397,7 @@ Developer features
.. _reference/cmdline/server/http:
HTTP
''''
~~~~
.. option:: --no-http
@@ -435,7 +434,7 @@ HTTP
.. _reference/cmdline/server/logging:
Logging
'''''''
~~~~~~~
By default, Odoo displays all logging of level_ ``info`` except for workflow
logging (``warning`` only), and log output is sent to ``stdout``. Various
@@ -530,7 +529,7 @@ customize the amount of logging output.
.. _reference/cdmline/workers:
Multiprocessing
'''''''''''''''
~~~~~~~~~~~~~~~
.. option:: --workers <count>
@@ -804,7 +803,7 @@ Processed files
.. _reference/cmdline/cloc/database-option:
With the :option:`--database` option
''''''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Odoo Cloc counts the lines in each file of extra installed modules in a
given database. In addition, it counts the Python lines of server actions and
@@ -837,12 +836,10 @@ per module. This is specified by the ``cloc_exclude`` entry of the manifest:
| For more information about the pattern syntax, see `glob
<https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob>`_.
.. _reference/cmdline/cloc/path-option:
With the :option:`--path` option
''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This method works the same as with the :ref:`--database option
<reference/cmdline/cloc/database-option>` if a manifest file is present in the given
@@ -865,7 +862,7 @@ Some file cannot be counted by Odoo Cloc.
Those file are reported at the end of the output.
Max file size exceeded
''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~
Odoo Cloc rejects any file larger than 25MB. Usually, source files are smaller
than 1 MB. If a file is rejected, it may be:
@@ -874,7 +871,7 @@ than 1 MB. If a file is rejected, it may be:
- A JavaScript library that should be placed in the :file:`static/lib` folder.
Syntax Error
''''''''''''
~~~~~~~~~~~~
Odoo Cloc cannot count the lines of code of a Python file with a syntax problem.
If an extra module contains such files, they should be fixed to allow the module to
File diff suppressed because it is too large Load Diff
@@ -288,7 +288,7 @@ For JavaScript, we use ESLint and you can find a `configuration file example her
<https://github.com/odoo/odoo/wiki/Javascript-coding-guidelines#use-a-linter>`_.
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 <https://www.pgadmin.org/download/pgadmin-4-apt/>`_ or `DBeaver
@@ -377,7 +377,5 @@ Here is a list of commands:
Quit the debugger. The program being executed is aborted.
----
Now that your server is running, it's time to start :ref:`writing your own application
<howto/rdtraining/03_newapp>`!
@@ -205,7 +205,7 @@ template is passed more than one record, it can produce one PDF report for all t
Using the Print menu in the list view with multiple records selected will demonstrate this.
Make a Report
---------------
-------------
Finally, you now know where to create your files and how the content of the files should look. Happy report making!
@@ -105,6 +105,7 @@ these options. A full example to reference while doing the exercises in this sec
Data
----
To fully enjoy our dashboard view, we will need good test data to populate it. Test data will
allow us to check that the resulting look and statistics are correct. It is a good idea to test
with data that will cover most or all of your expected use cases, but is also easy to verify with
@@ -130,6 +131,7 @@ data after you write your dashboard code and then test that your view is working
Aggregations
------------
Building a dashboard view is very similar to what you have previously done in
:ref:`howto/rdtraining/07_basicviews`. For the dashboard view, we use the `dashboard` root element
and choose from its possible tags (see all the possibilities and their attributes in the
@@ -164,6 +166,7 @@ covered in :ref:`howto/rdtraining/06_firstui`). Now let's make some dashboards!
Pie Charts
----------
Adding pie charts to dashboards is a piece of cake using the `<widget>` element. An example is:
.. code-block:: xml
@@ -192,6 +195,7 @@ the ``title`` for the pie chart, and that we're grouping it by property type.
Subviews
--------
Similar to how we can use the list view within the form view (we saw this automatically happen for
One2many relationships in :ref:`howto/rdtraining/08_relations`), we can add other views within our
dashboard view. The most commonly added are the pivot and graph views, but the cohort view is
@@ -248,6 +252,7 @@ model clean of unnecessary fields.
Model
-----
We will start with the more difficult part: our special report model. This file starts the same as
any other model, except that we add 2 attributes ``_auto`` and ``_rec_name``::
@@ -318,6 +323,7 @@ or use alias names that match.
View
----
Now that we have our model, we can make its dashboard view. There is no difference in how it's made,
except that its file is 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
@@ -334,6 +340,7 @@ remember how to add a ``menuitem``? If not, revisit :ref:`howto/rdtraining/06_fi
Extra Tips
----------
**Tip 1** A common mistake in SQL views is not considering the duplication of certain data
due to table JOINs. For example, in our **Goal**, we have a pie chart of the offers' property types.
We may be tempted to add a similar pie chart with a domain to only include canceled properties,
+7 -9
View File
@@ -28,12 +28,9 @@ From common CMS to Odoo
-----------------------
.. note::
If you always think and work in the same way, youll probably get the same results. If you want something completely new, then try something different.
..
Where is my header.php file?
**Where is my header.php file?**
This is usually the first question from a web designer used to working with Wordpress or Joomla and coming to Odoo for the first time.
@@ -185,7 +182,7 @@ Keep reading the tutorial to learn to how properly extend it with your own code.
Create a theme module
======================
=====================
Odoos themes are packaged like modules. Even if you are designing a very simple website for your company or client, you need to package the theme like an Odoo module.
@@ -810,7 +807,7 @@ Options allow publishers to edit a snippets appearance using the Website Buil
Using Website Builder functionalities, you can create snippet options easily and automatically add them to the UI.
Options group properties
-------------------------
------------------------
Options are wrapped in groups. Groups can have properties that define how the included options will interact with the user interface.
@@ -824,7 +821,7 @@ Options are wrapped in groups. Groups can have properties that define how the in
Defines the list of elements that the snippet can be dropped beside.
Default option methods
-----------------------
----------------------
Options apply standard CSS classes to the snippet. Depending on the method that you choose, the UI will behave differently.
@@ -1102,11 +1099,12 @@ Describe your page
------------------
Define keywords
'''''''''''''''
~~~~~~~~~~~~~~~
You should use appropriate, relevant keywords and synonyms for those keywords. You can define them for each page using the built-in “Promote” function found in the bar at the top.
Define a title and a description
''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Define them using the “Promote” function. Keep your page titles short and include the main keyword phrase for the page.
Good titles evoke an emotional response, ask a question or promise something.
+7 -6
View File
@@ -1,7 +1,5 @@
.. _reference/translations:
===================
Translating Modules
===================
@@ -118,7 +116,8 @@ of global variables.
return modules + ['your_module']
Variables
^^^^^^^^^
---------
**Don't** the extract may work but it will not translate the text correctly::
_("Scheduled meeting with %s" % invitee.name)
@@ -130,7 +129,8 @@ will fallback on source in case of missing placeholder in the translation)::
Blocks
^^^^^^
------
**Don't** split your translation in several blocks or multiples lines::
# bad, trailing spaces, blocks out of context
@@ -152,7 +152,8 @@ Blocks
"this sales order request.")
Plural
^^^^^^
------
**Don't** pluralize terms the English-way::
msg = _("You have %(count)s invoice", count=invoice_count)
@@ -167,7 +168,7 @@ Plural
msg = _("You have one invoice")
Read vs Run Time
^^^^^^^^^^^^^^^^
----------------
**Don't** invoke translation lookup at server launch::
+37 -40
View File
@@ -1,8 +1,8 @@
:orphan:
=============================
==========================
Customizing the web client
=============================
==========================
.. note::
@@ -10,7 +10,6 @@ Customizing the web client
but meanwhile, this tutorial will probably be frustrating to follow, since it
was written a long time ago.
.. highlight:: javascript
.. default-domain:: js
@@ -30,7 +29,6 @@ or extend existing business systems of Odoo, see :doc:`backend`.
It also requires :ref:`an installed Odoo <setup/install>`, and Git_.
A Simple Module
===============
@@ -110,7 +108,9 @@ sub-folders are conventional and not strictly necessary.
Which only prints a small message in the browser's console.
The files in the ``static`` folder, need to be defined within the module in order for them to be loaded correctly. Everything in ``src/xml`` is defined in ``__manifest__.py`` while the contents of ``src/css`` and ``src/js`` are defined in ``petstore.xml``, or a similar file.
The files in the ``static`` folder, need to be defined within the module in order for them to be
loaded correctly. Everything in ``src/xml`` is defined in ``__manifest__.py`` while the contents of
``src/css`` and ``src/js`` are defined in ``petstore.xml``, or a similar file.
.. warning::
@@ -503,11 +503,10 @@ must be explicitly cleaned up (because the garbage collector will not handle
them), you can override :func:`~odoo.Widget.destroy`.
.. danger::
when overriding :func:`~odoo.Widget.destroy`, ``_super()``
*must always* be called otherwise the widget and its children are not
correctly cleaned up leaving possible memory leaks and "phantom events",
even if no error is displayed
when overriding :func:`~odoo.Widget.destroy`, ``_super()``
*must always* be called otherwise the widget and its children are not
correctly cleaned up leaving possible memory leaks and "phantom events",
even if no error is displayed
The QWeb Template Engine
========================
@@ -537,16 +536,15 @@ characteristics:
:class:`~odoo.Widget` without relying on QWeb)
.. note::
The rationale behind using QWeb instead of existing javascript template
engines is the extensibility of pre-existing (third-party) templates, much
like Odoo :ref:`views <reference/views>`.
The rationale behind using QWeb instead of existing javascript template
engines is the extensibility of pre-existing (third-party) templates, much
like Odoo :ref:`views <reference/views>`.
Most javascript template engines are text-based which precludes easy
structural extensibility where an XML-based templating engine can be
generically altered using e.g. XPath or CSS and a tree-alteration DSL (or
even just XSLT). This flexibility and extensibility is a core
characteristic of Odoo, and losing it was considered unacceptable.
Most javascript template engines are text-based which precludes easy
structural extensibility where an XML-based templating engine can be
generically altered using e.g. XPath or CSS and a tree-alteration DSL (or
even just XSLT). This flexibility and extensibility is a core
characteristic of Odoo, and losing it was considered unacceptable.
Using QWeb
----------
@@ -598,14 +596,13 @@ usages:
sub-widget also gets a red background
.. warning::
templates should have a single non-``t`` root element, especially if
they're set as a widget's :attr:`~odoo.Widget.template`. If there are
multiple "root elements", results are undefined (usually only the first
root element will be used and the others will be ignored)
templates should have a single non-``t`` root element, especially if
they're set as a widget's :attr:`~odoo.Widget.template`. If there are
multiple "root elements", results are undefined (usually only the first
root element will be used and the others will be ignored)
QWeb Context
''''''''''''
~~~~~~~~~~~~
QWeb templates can be given data and can contain basic display logic.
@@ -659,7 +656,7 @@ Result:
<div>Hello Mordecai</div>
Template Declaration
''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~
We've seen how to *render* QWeb templates, let's now see the syntax of
the templates themselves.
@@ -683,7 +680,7 @@ it can be called using :func:`QWeb.render`. It can only be used at the
top-level of a template file.
Escaping
''''''''
~~~~~~~~
The ``t-esc`` directive can be used to output text:
@@ -707,7 +704,7 @@ or method calls:
<div><t t-esc="name.toUpperCase()"/></div>
Outputting HTML
'''''''''''''''
~~~~~~~~~~~~~~~
To inject HTML in the page being rendered, use ``t-raw``. Like ``t-esc`` it
takes an arbitrary Javascript expression as parameter, but it does not
@@ -724,7 +721,7 @@ perform an HTML-escape step.
vulnerabilities
Conditionals
''''''''''''
~~~~~~~~~~~~
QWeb can have conditional blocks using ``t-if``. The directive takes an
arbitrary expression, if the expression is falsy (``false``, ``null``, ``0``
@@ -748,7 +745,7 @@ or an empty string) the whole block is suppressed, otherwise it is displayed.
local variable if it's a complex or expensive expression.
Iteration
'''''''''
~~~~~~~~~
To iterate on a list, use ``t-foreach`` and ``t-as``. ``t-foreach`` takes an
expression returning a list to iterate on ``t-as`` takes a variable name to
@@ -768,7 +765,7 @@ bind to each item during iteration.
(dictionaries)
Defining attributes
'''''''''''''''''''
~~~~~~~~~~~~~~~~~~~
QWeb provides two related directives to define computed attributes:
:samp:`t-att-{name}` and :samp:`t-attf-{name}`. In either case, *name* is the
@@ -799,7 +796,7 @@ literal and partially computed such as a class:
</div>
Calling other templates
'''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~
Templates can be split into sub-templates (for simplicity, maintainability,
reusability or to avoid excessive markup nesting).
@@ -829,12 +826,12 @@ rendering the ``A`` template will result in:
Sub-templates inherit the rendering context of their caller.
To Learn More About QWeb
''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~
For a QWeb reference, see :ref:`reference/qweb`.
Exercise
''''''''
~~~~~~~~
.. exercise:: Usage of QWeb in Widgets
@@ -1667,7 +1664,7 @@ In Odoo Web, the component responsible for handling and reacting to these
actions is the *Action Manager*.
Using the Action Manager
''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~
The action manager can be invoked explicitly from javascript code by creating
a dictionary describing :ref:`an action <reference/actions>` of the right
@@ -1811,7 +1808,7 @@ Much of Odoo web's usefulness (and complexity) resides in views. Each view
type is a way of displaying a model in the client.
The View Manager
''''''''''''''''
~~~~~~~~~~~~~~~~
When an ``ActionManager`` instance receive an action of type
``ir.actions.act_window``, it delegates the synchronization and handling of
@@ -1823,7 +1820,7 @@ multiple views depending on the original action's requirements:
:width: 40%
The Views
'''''''''
~~~~~~~~~
Most :ref:`Odoo views <reference/views>` are implemented through a subclass
of :class:`odoo.web.View` which provides a bit of generic basic structure
@@ -1932,14 +1929,14 @@ interface and the ``AbstractField`` class directly in the code of the Odoo web
client.
Creating a New Type of Field
''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In this part we will explain how to create a new type of field. The example
here will be to re-implement the ``FieldChar`` class and progressively explain
each part.
Simple Read-Only Field
""""""""""""""""""""""
**********************
Here is a first implementation that will only display text. The
user will not be able to modify the content of the field.
@@ -1979,7 +1976,7 @@ none is specified by the form view (here we assume the default value of a
``char`` field should be an empty string).
Read-Write Field
""""""""""""""""
****************
Read-only fields, which only display content and don't allow the
user to modify it can be useful, but most fields in Odoo also allow editing.
@@ -408,7 +408,7 @@ how the POS interface works.
.. _reference/actions/cron:
Automated Actions (``ir.cron``)
======================================
===============================
Actions triggered automatically on a predefined frequency.
+1 -1
View File
@@ -77,7 +77,7 @@ following attributes:
Requires an :term:`external id`, defaults to ``True``.
``field``
----------
---------
Each record can be composed of ``field`` tags, defining values to set when
creating the record. A ``record`` with no ``field`` will use all default
+9 -12
View File
@@ -20,7 +20,7 @@ Messaging integration
---------------------
Basic messaging system
''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~
Integrating messaging features to your model is extremely easy. Simply inheriting
the ``mail.thread`` model and adding the messaging fields (and their appropriate
@@ -192,9 +192,8 @@ a date or an e-mail address, add CC's addresses as followers, etc.).
:return: True
:rtype: bool
Logging changes
'''''''''''''''
~~~~~~~~~~~~~~~
The ``mail`` module adds a powerful tracking system on fields, allowing you
to log changes to specific fields in the record's chatter. To add tracking
@@ -221,9 +220,8 @@ to a field, simple set the tracking attribute to True.
well to give more context about the notification (even if the name did not
change).
Subtypes
''''''''
~~~~~~~~
Subtypes give you more granular control over messages. Subtypes act as a classification
system for notifications, allowing subscribers to a document to customize the
@@ -318,9 +316,8 @@ can override the ``_track_subtype()`` function:
return self.env.ref('my_module.mt_state_change')
return super(BusinessTrip, self)._track_subtype(init_values)
Customizing notifications
'''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~
When sending notifications to followers, it can be quite useful to add buttons in
the template to allow quick actions directly from the e-mail. Even a simple button
@@ -469,7 +466,7 @@ The urls in the actions list can be generated automatically by calling the
that can sometimes be boring, I choose the former instead of the latter.
Overriding defaults
'''''''''''''''''''
~~~~~~~~~~~~~~~~~~~
There are several ways you can customize the behaviour of ``mail.thread`` models,
including (but not limited to):
@@ -510,7 +507,7 @@ the outside, allowing users or customers to quickly create records in your
database without needing to connect to Odoo directly.
Aliases vs. Incoming Mail Gateway
'''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some people use the Incoming Mail Gateway for this same purpose. You still need
a correctly configured mail gateway to use aliases, however a single
@@ -531,7 +528,7 @@ Aliases have several advantages over Mail Gateways:
Alias support integration
'''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~
Aliases are usually configured on a parent model which will then create specific
record when contacted by e-mail. For example, Project have aliases to create tasks
@@ -977,7 +974,7 @@ The rating mixin allows sending email to ask for customer rating, automatic
transitioning in a kanban processes and aggregating statistics on your ratings.
Adding rating on your model
'''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~
To add rating support, simply inherit the ``rating.mixin`` model:
@@ -1010,7 +1007,7 @@ The behaviour of the mixin adapts to your model:
``mail.thread``)
Send rating requests by e-mail
''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you wish to send emails to request a rating, simply generate an e-mail with
links to the rating object. A very basic email template could look like this:
+13 -14
View File
@@ -1,4 +1,3 @@
.. _reference/orm:
=======
@@ -150,7 +149,7 @@ Advanced Fields
.. _reference/fields/date:
Date(time) Fields
'''''''''''''''''
~~~~~~~~~~~~~~~~~
:class:`Dates <odoo.fields.Date>` and :class:`Datetimes <odoo.fields.Datetime>`
are very important fields in any kind of business application.
@@ -211,7 +210,7 @@ These helpers are also available by importing `odoo.tools.date_utils`.
.. _reference/fields/relational:
Relational Fields
'''''''''''''''''
~~~~~~~~~~~~~~~~~
.. autoclass:: Many2one()
@@ -225,7 +224,7 @@ Relational Fields
:member-order: bysource
Pseudo-relational fields
''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~
.. autoclass:: Reference()
@@ -234,7 +233,7 @@ Pseudo-relational fields
.. _reference/fields/compute:
Computed Fields
'''''''''''''''
~~~~~~~~~~~~~~~
Fields can be computed (instead of read straight from the database) using the
``compute`` parameter. **It must assign the computed value to the field**. If
@@ -325,7 +324,7 @@ it uses the values of other *fields*, it should specify those fields using
.. _reference/fields/related:
Related fields
''''''''''''''
~~~~~~~~~~~~~~
A special case of computed fields are *related* (proxy) fields, which provide
the value of a sub-field on the current record. They are defined by setting
@@ -405,7 +404,7 @@ Automatic fields
.. _reference/fields/automatic/log_access:
Access Log fields
'''''''''''''''''
~~~~~~~~~~~~~~~~~
These fields are automatically set and updated if
:attr:`~odoo.models.BaseModel._log_access` is enabled. It can be
@@ -461,10 +460,10 @@ behavior is desired:
:class:`~odoo.fields.Boolean`
.. .. attribute:: sequence
..
.. Alterable ordering criteria, allows drag-and-drop reordering of models
.. in list views.
..
.. :class:`~odoo.fields.Integer`
.. attribute:: state
@@ -769,7 +768,7 @@ Search/Read
.. automethod:: Model.read_group
Fields/Views
''''''''''''
~~~~~~~~~~~~
.. automethod:: Model.fields_get
@@ -778,7 +777,7 @@ Fields/Views
.. _reference/orm/domains:
Search domains
''''''''''''''
~~~~~~~~~~~~~~
A domain is a list of criteria, each criterion being a triple (either a
``list`` or a ``tuple``) of ``(field_name, operator, value)`` where:
@@ -940,14 +939,14 @@ Recordsets therefore provide the following operations returning recordsets thems
(when possible):
Filter
''''''
~~~~~~
.. automethod:: Model.filtered
.. automethod:: Model.filtered_domain
Map
'''
~~~
.. automethod:: Model.mapped
@@ -962,7 +961,7 @@ Map
records.partner_id.mapped('name') # == records.mapped('partner_id.name')
Sort
''''
~~~~
.. automethod:: Model.sorted
@@ -164,6 +164,7 @@ More parameters can be passed as a query string
Useful Remarks
--------------
* Twitter Bootstrap and FontAwesome classes can be used in your report
template
* Local CSS can be put directly in the template
@@ -277,6 +278,7 @@ the template, such as data from additional models:
Custom fonts
============
If you want to use custom fonts you will need to add your custom font and the related less/CSS to the ``web.reports_assets_common`` assets bundle.
Adding your custom font(s) to ``web.assets_common`` or ``web.assets_backend`` will not make your font available in QWeb reports.
@@ -225,6 +225,7 @@ properly.
Bypassing the ORM
-----------------
You should never use the database cursor directly when the ORM can do the same
thing! By doing so you are bypassing all the ORM features, possibly the
automated behaviours like translations, invalidation of fields, ``active``,
@@ -250,6 +251,7 @@ less secure.
SQL injections
~~~~~~~~~~~~~~
Care must be taken not to introduce SQL injections vulnerabilities when using
manual SQL queries. The vulnerability is present when user input is either
incorrectly filtered or badly quoted, allowing an attacker to introduce
@@ -420,6 +422,7 @@ likely it is to break things.
Evaluating content
------------------
Some may want to ``eval`` to parse user provided content. Using ``eval`` should
be avoided at all cost. A safer, sandboxed, method :class:`~odoo.tools.safe_eval`
can be used instead but still gives tremendous capabilities to the user running
@@ -1,10 +1,8 @@
.. _reference/testing:
===============
============
Testing Odoo
===============
============
There are many ways to test an application. In Odoo, we have three kinds of
tests
@@ -280,12 +280,13 @@ using the view in the kanban arch (a specific example is the helpdesk dashboard)
need to have a valid arch field.
Promises and asynchronous code
===============================
==============================
For a very good and complete introduction to promises, please read this excellent article https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/async%20%26%20performance/ch3.md
Creating new Promises
-----------------------
---------------------
- turn a constant into a promise
There are 2 static functions on Promise that create a resolved or rejected promise based on a constant:
@@ -383,6 +384,7 @@ Creating new Promises
Waiting for Promises
--------------------
- waiting for a number of Promises
if you have multiple promises that all need to be waited, you can convert them into a single promise that will be resolved when all the promises are resolved using Promise.all(arrayOfPromises).
@@ -486,7 +488,7 @@ Error handling
Testing asynchronous code
--------------------------
-------------------------
- using promises in tests
In the tests code, we support the latest version of Javascript, including primitives like `async` and `await`. This makes using and waiting for promises very easy.
@@ -263,7 +263,7 @@ within the same Odoo addon.
.. _frontend/modules/odoo_module:
Odoo Module System
===================
==================
Odoo has defined a small module system (located in the file
:file:`addons/web/static/src/js/boot.js`, which needs to be loaded first). The Odoo
@@ -371,7 +371,7 @@ If an error happens, it will be logged (in debug mode) in the console:
Modules who depend on a missing or a failed module
Asynchronous modules
---------------------
--------------------
It can happen that a module needs to perform some work before it is ready. For
example, it could do an rpc to load some data. In that case, the module can
@@ -1,11 +1,10 @@
.. highlight:: javascript
.. default-domain:: js
=====================
====================
Javascript Reference
=====================
====================
This document presents the Odoo Javascript framework. This
framework is not a large application in term of lines of code, but it is quite
@@ -15,7 +14,7 @@ records in the database. It is even possible to use the web client to modify
the interface of the web client.
Overview
=========
========
The Javascript framework is designed to work with three main use cases:
@@ -53,7 +52,7 @@ action manager) actually creates and destroys many sub components. The state is
highly dynamic, and each widget could be destroyed at any time.
Overview of web client JS code
-------------------------------------
------------------------------
Here, we give a very quick overview on the web client code, in
the *web/static/src/js* addon. Note that it is deliberately not exhaustive.
@@ -105,7 +104,7 @@ are a few things you can try to solve the issue:
Loading Javascript Code
========================
=======================
Large applications are usually broken up into smaller files, that need to be
connected together. Some file may need to use some part of code defined in
@@ -146,8 +145,6 @@ not the primary way to write javascript code.
.. note::
Native javascript modules are the primary way to define javascript code.
Class System
============
@@ -204,7 +201,6 @@ framework will secretly rebind a special method: *_super* to the currently
called method. This allows us to use *this._super* whenever we need to call a
parent method.
.. code-block:: javascript
var Animal = require('web.Animal');
@@ -248,7 +244,6 @@ of them in the new class.
In this example, the *Hamster* class is a subclass of Animal, but it also mix
the DanceMixin in.
Patching an existing class
--------------------------
@@ -273,7 +268,6 @@ the way Odoo is structured, it is sometimes necessary in one addon to modify
the behavior of a widget/class defined in another addon. Note that it will
modify all instances of the class, even if they have already been created.
Widgets
=======
@@ -524,7 +518,6 @@ Widget API
:param Element element: a DOM element or jQuery object to set as
the widget's DOM root
Inserting a widget in the DOM
-----------------------------
@@ -558,7 +551,7 @@ and are charged with three tasks:
* starting the widget, and returning the result of starting it
Widget Guidelines
----------------------
-----------------
* Identifiers (``id`` attribute) should be avoided. In generic applications
and modules, ``id`` limits the re-usability of components and tends to make
@@ -668,7 +661,6 @@ in order to make the web client slightly lighter. In that case, we can use the
With this, the *Counter* widget will load the xmlDependencies files in its
*willStart* method, so the template will be ready when the rendering is performed.
Event system
============
@@ -760,9 +752,8 @@ The previous example can be updated to use the custom event system:
... this.trigger_up('valuechange', {value: someValue});
Registries
===========
==========
A common need in the Odoo ecosystem is to extend/change the behaviour of the
base system from the outside (by installing an application, i.e. a different
@@ -799,7 +790,6 @@ action registry
action. In version 11, each value should simply be a subclass of *Widget*.
However, in version 12, the values are required to be *AbstractAction*.
Communication between widgets
=============================
@@ -867,7 +857,6 @@ Cross component
},
});
In this example, we use the bus exported by *web.core*, but this is not
required. A bus could be created for a specific purpose.
@@ -884,7 +873,7 @@ events, these events bubble up to a service provider, which will ask a service
to perform a task, then maybe return an answer.
Service
--------
-------
A service is an instance of the *AbstractService* class. It basically only has
a name and a few methods. Its job is to perform some work, typically something
@@ -916,7 +905,6 @@ dispatch the custom events. In the *backend* (web client), this is done by the
main web client instance. Note that the code for the service provider comes from
the *ServiceProviderMixin*.
Widget
------
@@ -975,7 +963,7 @@ may need to directly call a controller (available on some route).
});
Notifications
==============
=============
The Odoo framework has a standard way to communicate various information to the
user: notifications, which are displayed on the top right of the user interface.
@@ -1010,9 +998,9 @@ The notification system in Odoo is designed with the following components:
- an helper function in *ServiceMixin*: *displayNotification*
Displaying a notification
-------------------------
The most common way to display a notification is by using the method that come
from the *ServiceMixin*:
@@ -1102,7 +1090,6 @@ the class variable SystrayMenu.items.
SystrayMenu.Items.push(MySystrayWidget);
Ordering
--------
@@ -1116,7 +1103,6 @@ left).
MySystrayWidget.prototype.sequence = 100;
Translation management
======================
@@ -1211,7 +1197,7 @@ client for everyone), and for data which is required early in the initialization
process.
Views
======
=====
The word 'view' has more than one meaning. This section is about the design of
the javascript code of the views, not the structure of the *arch* or anything
@@ -1220,7 +1206,6 @@ else.
In 2017, Odoo replaced the previous view code with a new architecture. The
main need was to separate the rendering logic from the model logic.
Views (in a generic sense) are now described with 4 pieces: a View, a
Controller, a Renderer and a Model. The API of these 4 pieces is described in
the AbstractView, AbstractController, AbstractRenderer and AbstractModel classes.
@@ -2094,6 +2079,7 @@ reference (FieldReference)
Widgets
-------
week_days (WeekDays)
This field displays a list of checkboxes for week days, 1 checkbox for each day
and allow the user to select a subset of the choices.
@@ -2166,7 +2152,6 @@ Registering the client action:
<field name="tag">my-custom-action</field>
</record>
Using the control panel
-----------------------
+13 -15
View File
@@ -1,9 +1,8 @@
.. _reference/mobile:
==================
=================
Mobile JavaScript
==================
=================
Introduction
============
@@ -11,15 +10,16 @@ Introduction
In Odoo 10.0 we released a mobile app which allows you to access all **Odoo apps**
(even your customized modules).
The application is a combination of **Odoo Web** and **Native Mobile
components**. In other words it is a Odoo Web instance loaded inside a native, mobile, WebView container.
The application is a combination of **Odoo Web** and **Native Mobile components**. In other words it
is a Odoo Web instance loaded inside a native, mobile, WebView container.
This page documents how you can access mobile native components like Camera,
Vibration, Notification and Toast through Odoo Web (via JavaScript). For this, you
do not need to be a mobile developer, if you know Odoo JavaScript API you can
access all available mobile features.
.. warning:: These features work with **Odoo Enterprise 10.0+** only
.. warning::
These features work with **Odoo Enterprise 10.0+** only
How does it work?
=================
@@ -64,7 +64,7 @@ Methods
a data JSON dictionary
Show Toast in device
.....................
~~~~~~~~~~~~~~~~~~~~
.. js:function:: showToast
@@ -80,10 +80,8 @@ remains visible and interactive.
.. image:: mobile/toast.png
Vibrating device
................
~~~~~~~~~~~~~~~~
.. js:function:: vibrate
@@ -97,7 +95,7 @@ Vibrate mobile device with given duration.
mobile.methods.vibrate({'duration': 100});
Show snackbar with action
.........................
~~~~~~~~~~~~~~~~~~~~~~~~~
.. js:function:: showSnackBar
@@ -122,7 +120,7 @@ displayed at a time.
.. image:: mobile/snackbar.png
Showing notification
.....................
~~~~~~~~~~~~~~~~~~~~
.. js:function:: showNotification
@@ -143,7 +141,7 @@ view at any time.
Create contact in device
.........................
~~~~~~~~~~~~~~~~~~~~~~~~
.. js:function:: addContact
@@ -176,7 +174,7 @@ Create a new device contact with the given contact details.
.. image:: mobile/mobile_contact_create.png
Scanning barcodes
..................
~~~~~~~~~~~~~~~~~
.. js:function:: scanBarcode
@@ -198,7 +196,7 @@ The barcode API can read the following barcode formats:
});
Switching account in device
...........................
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. js:function:: switchAccount
@@ -350,7 +350,7 @@ open themselves on mouse hover, without the need for a click.
Example: Direct Siblings Dropdown
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When one dropdown toggler is clicked (**File** , **Edit** or **About**), the
others will open themselves on hover.
+10 -11
View File
@@ -257,9 +257,8 @@ exists in 3 different forms:
setting variables
=================
QWeb allows creating variables from within the template, to memoize a
computation (to use it multiple times), give a piece of data a clearer name,
...
QWeb allows creating variables from within the template, to memoize a computation (to use it
multiple times), give a piece of data a clearer name, ...
This is done via the ``set`` directive, which takes the name of the variable
to create. The value to set can be provided in two ways:
@@ -374,7 +373,7 @@ templates:
will not strip that information from safe content.
Creating safe content using :class:`~markupsafe.Markup`
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See the official documentation for explanations, but the big advantage of
:class:`~markupsafe.Markup` is that it's a very rich type overrinding
@@ -471,12 +470,12 @@ Exclusive directives
--------------------
Asset bundles
'''''''''''''
~~~~~~~~~~~~~
.. todo:: have fme write these up because I've no idea how they work
"smart records" fields formatting
'''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``t-field`` directive can only be used when performing field access
(``a.b``) on a "smart" record (result of the ``browse`` method). It is able
@@ -503,7 +502,7 @@ Helpers
-------
Request-based
'''''''''''''
~~~~~~~~~~~~~
Most Python-side uses of QWeb are in controllers (and during HTTP requests),
in which case templates stored in the database (as
@@ -520,7 +519,7 @@ This automatically creates a :class:`~odoo.http.Response` object which can
be returned from the controller (or further customized to suit).
View-based
''''''''''
~~~~~~~~~~
At a deeper level than the previous helper is the ``render`` method on
``ir.ui.view``:
@@ -576,7 +575,7 @@ Exclusive directives
--------------------
Defining templates
''''''''''''''''''
~~~~~~~~~~~~~~~~~~
The ``t-name`` directive can only be placed at the top-level of a template
file (direct children to the document root)::
@@ -595,7 +594,7 @@ are related (e.g. called sub-templates) it is customary to use dot-separated
names to indicate hierarchical relationships.
Template inheritance
''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~
Template inheritance is used to either:
- Alter existing templates in-place, e.g. to add information to templates
@@ -632,7 +631,7 @@ Extension inheritance (in-place transformation)::
</t>
Old inheritance mechanism (deprecated)
''''''''''''''''''''''''''''''''''''''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Template inheritance is performed via the ``t-extend`` directive which takes
the name of the template to alter as parameter.
@@ -667,8 +667,7 @@ When a rpc fails, then:
* the promise representing the rpc is rejected, so the calling code will crash,
unless it handles the situation
*
an event ``RPC_ERROR`` is triggered on the main application bus. The event payload
* an event ``RPC_ERROR`` is triggered on the main application bus. The event payload
contains a description of the cause of the error:
If it is a server error (the server code threw an exception). In that case