[MOV] documentation structure reorganization

This commit aims to improve the documentation's navigability by
redefining some categories' purposes and titles.

There is a redirection rule for each documentation page moved.
This ensures that users won't have a 404 error message.

task-3217827

closes odoo/documentation#8064

Signed-off-by: Jonathan Castillo (jcs) <jcs@odoo.com>
This commit is contained in:
Jonathan Castillo (jcs)
2024-03-04 12:02:08 +01:00
parent dbe0300b84
commit 0249d9d0a6
563 changed files with 644 additions and 643 deletions
@@ -0,0 +1,249 @@
===============================
Automated actions (automations)
===============================
Automated actions are used to trigger automatic changes based on user actions (e.g., apply a
modification when a field is set to a specific value) or on time conditions (e.g., archive a record
7 days after its last update).
To create an automated action with Studio, go to :guilabel:`Automations` from anywhere within
Studio.
For every automated action you create, the following elements should be defined: the
:ref:`studio/automated-actions/model`, the :ref:`studio/automated-actions/trigger`, the
:ref:`studio/automated-actions/apply-on`, and the :ref:`studio/automated-actions/action`.
.. example::
.. image:: automated_actions/automated-action-example.png
:align: center
:alt: Example of an automated action on the Subscription model
.. _studio/automated-actions/model:
Model
=====
Select the model where the automated action should be applied.
.. note::
The model you are on when you click on :guilabel:`Automations` is pre-selected by default.
.. _studio/automated-actions/trigger:
Trigger
=======
Define when the automated action should be applied. Six triggers are available.
.. _studio/automated-actions/trigger/on-creation:
On Creation
-----------
The action is triggered when a record is created and then saved.
.. _studio/automated-actions/trigger/on-update:
On Update
---------
The action is triggered when a previously saved record is edited and then saved.
- Use :guilabel:`Trigger Fields` to specify which fields - and only those - trigger the action on
their update.
- To detect when a record changes from one state to another, define a :guilabel:`Before Update
Domain` filter, which checks if the condition is satisfied before the record is updated. Then set
an :ref:`studio/automated-actions/apply-on` filter, which checks if the condition is met after the
record is updated.
.. example::
If you want the automated action to happen when an email address is set on a contact, define
the :guilabel:`Before Update Domain` to `Email is not set`, and the :guilabel:`Apply on`
domain to `Email is set`.
.. image:: automated_actions/on-update-trigger-example.png
:align: center
:alt: Example of an On Update trigger
.. _studio/automated-actions/trigger/on-creation-update:
On Creation & Update
--------------------
The action is triggered when a record is created and saved or edited afterward and saved.
.. _studio/automated-actions/trigger/on-deletion:
On Deletion
-----------
The action is triggered when a record is deleted.
.. note::
This trigger is rarely used, as archiving records is usually preferred to deletion.
.. _studio/automated-actions/trigger/form-modification:
Based on Form Modification
--------------------------
The action is triggered when any change is done to a trigger field's value on the :ref:`Form view
<studio/views/general/form>`, even before saving the record. This trigger only works on the user
interface when a modification is made by a user. If the field is changed through another action and
not by the user, the action will not run.
.. note::
This trigger can only be used with the :ref:`Execute Python Code action
<studio/automated-actions/action/python-code>`, so development is required.
.. _studio/automated-actions/trigger/timed-condition:
Based on Timed Condition
------------------------
The action is triggered when a trigger field's date or date & time value is reached.
- To trigger the action after the :guilabel:`Trigger Date`, add a number of minutes, hours, days, or
months under :guilabel:`Delay after trigger date`. To trigger the action before, add a negative
number instead.
.. example::
If you want to send a reminder email 30 minutes before the start of a calendar event, select
the :guilabel:`Start (Calendar Event)` under :guilabel:`Trigger Date` and set the
:guilabel:`Delay after trigger date` to **-30** :guilabel:`Minutes`.
.. image:: automated_actions/timed-condition-trigger-example.png
:align: center
:alt: Example of a Based on Timed Condition trigger
.. note::
By default, the scheduler checks for trigger dates every 4 hours.
.. _studio/automated-actions/apply-on:
Apply on
========
Define on which records of the model the automated action should be applied. It works the same way
as when you apply filters on a model.
.. _studio/automated-actions/action:
Action
======
Determine what the automated action should do (server action). There are eight types of action to
choose from.
.. _studio/automated-actions/action/python-code:
Execute Python Code
-------------------
The action is used to execute Python code. The available variables are described on the
:guilabel:`Python Code` tab, which is also used to write your code, or on the :guilabel:`Help` tab.
- To allow the action to be run through the website, tick :guilabel:`Available on the Website` and
add a :guilabel:`Website Path`.
.. _studio/automated-actions/action/new-record:
Create a new Record
-------------------
The action is used to create a new record on any model.
.. note::
Selecting a :guilabel:`Target Model` is only required if you want to target another model than
the one you are on.
- To link the record that triggered the creation of the new record, select a field under
:guilabel:`Link Field`. For example, you could create a contact automatically when a lead is
turned into an opportunity.
- :guilabel:`Data to Write` tab: the tab is used to specify the new record's values. After selecting
a :guilabel:`Field`, select its :guilabel:`Evaluation Type`:
- :guilabel:`Value`: used to directly give the field's raw value in the :guilabel:`Value` column.
- :guilabel:`Reference`: used to select the record under the :guilabel:`Record` column and let
Studio add the internal ID in the :guilabel:`Value` column.
.. example::
If an automated action creates a new task in a project, you can assign it to a specific user
by setting the :guilabel:`Field` to :guilabel:`Responsible User (Project)`, the
:guilabel:`Evaluation Type` to :guilabel:`Reference`, and the :guilabel:`Record` to a
specific user.
.. image:: automated_actions/new-record-example.png
:align: center
:alt: Example of a Create a new Record action
- :guilabel:`Python expression`: used to dynamically define the newly created records value for a
field using Python code in the :guilabel:`Value` column.
.. _studio/automated-actions/action/update-record:
Update the Record
-----------------
The action is used to set value(s) for field(s) of any record on the current model.
.. note::
The process to fill in the :guilabel:`Data to Write` tab is the same as described under
:ref:`studio/automated-actions/action/new-record`.
.. _studio/automated-actions/action/several-actions:
Execute several actions
-----------------------
The action is used to trigger multiple actions at the same time. To do so, click on :guilabel:`Add a
line` under the :guilabel:`Actions` tab. In the :guilabel:`Child Actions` pop-up, click on
:guilabel:`Create` and configure the action.
.. _studio/automated-actions/action/send-email:
Send Email
----------
The action is used to send an email to a contact linked to a specific record. To do so, select or
create an :guilabel:`Email Template`.
.. _studio/automated-actions/action/add-followers:
Add Followers
-------------
The action is used to subscribe existing contacts to the record.
.. _studio/automated-actions/action/next-activity:
Create Next Activity
--------------------
The action is used to schedule a new activity linked to the record. Use the :guilabel:`Activity` tab
to set it up as usual, but instead of the :guilabel:`Assigned to` field, select an
:guilabel:`Activity User Type`. Select :guilabel:`Specific User` and add the user under
:guilabel:`Responsible` if the activity should always be assigned to the same user. To dynamically
target a user linked to the record, select :guilabel:`Generic User From Record` instead and change
the :guilabel:`User field name` if necessary.
.. example::
After a lead is turned into an opportunity, you want your automated action to set up a call for
the user responsible for the lead. To do so, set the :guilabel:`Activity` to :guilabel:`Call`
and set the :guilabel:`Activity User Type` to :guilabel:`Generic User From Record`.
.. image:: automated_actions/next-activity-example.png
:align: center
:alt: Example of a Create Next Activity action
.. _studio/automated-actions/action/send-sms:
Send SMS Text Message
---------------------
The action is used to send an SMS to a contact linked to the record. To do so, select or create an
:guilabel:`SMS Template`.
.. tip::
If you want sent messages to be logged in the Chatter, tick :guilabel:`Log as Note`.
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

+493
View File
@@ -0,0 +1,493 @@
==================
Fields and widgets
==================
Fields structure the models of a database. If you picture a model as a table or spreadsheet, fields
are the columns where data is stored in the records (i.e., the rows). Fields also define the type of
data that is stored within them. How the data is presented and formatted on the :abbr:`UI (User
Interface)` is defined by their widget.
From a technical point of view, there are 15 field types in Odoo. However, you can choose from 20
fields in Studio, as some field types are available more than once with a different default widget.
.. tip::
:guilabel:`New Fields` can only be added to the :ref:`studio/views/general/form` and
:ref:`studio/views/multiple-records/list` views. On other views, you can only add
:guilabel:`Existing Fields` :dfn:`(fields already on the model)`.
.. _studio/fields/simple-fields:
Simple fields
=============
Simple fields contain basic values, such as text, numbers, files, etc.
.. note::
Non-default widgets, when available, are presented as bullet points below.
.. _studio/fields/simple-fields/text:
Text (`char`)
-------------
The :guilabel:`Text` field is used for short text containing any character. One text line is
displayed when filling out the field.
- :guilabel:`Badge`: displays the value inside a rounded shape, similar to a tag. The value cannot
be edited on the UI, but a default value can be set.
- :guilabel:`Copy to Clipboard`: users can copy the value by clicking a button.
- :guilabel:`E-mail`: the value becomes a clickable *mailto* link.
- :guilabel:`Image`: displays an image using a URL. The value cannot be edited manually, but a
default value can be set.
.. note::
This works differently than selecting the :ref:`Image field
<studio/fields/simple-fields/image>` directly, as the image is not stored in Odoo when using a
:guilabel:`Text` field with the :guilabel:`Image` widget. For example, it can be useful if you
want to save disk space.
- :guilabel:`Phone`: the value becomes a clickable *tel* link.
.. tip::
Tick :guilabel:`Enable SMS` to add an option to send an SMS directly from Odoo next to the
field.
- :guilabel:`URL`: the value becomes a clickable URL.
.. example::
.. image:: fields/text-examples.png
:align: center
:alt: Examples of Text fields with different widgets
.. _studio/fields/simple-fields/multiline-text:
Multiline Text (`text`)
-----------------------
The :guilabel:`Multiline Text` field is used for longer text containing any type of character. Two
text lines are displayed on the UI when filling out the field.
- :guilabel:`Copy to Clipboard`: users can copy the value by clicking a button.
.. example::
.. image:: fields/multiline-text-examples.png
:align: center
:alt: Examples of Multiline Text fields with different widgets
.. _studio/fields/simple-fields/integer:
Integer (`integer`)
-------------------
The :guilabel:`Integer` field is used for all integer numbers (:dfn:`positive, negative, or zero,
without a decimal`).
- :guilabel:`Percentage Pie`: displays the value inside a percentage circle, usually for a computed
value. The value cannot be edited on the UI, but a default value can be set.
- :guilabel:`Progress Bar`: displays the value next to a percentage bar, usually for a computed
value. The field cannot be edited manually, but a default value can be set.
- :guilabel:`Handle`: displays a drag handle icon to order records manually in :ref:`List view
<studio/views/multiple-records/list>`.
.. example::
.. image:: fields/integer-examples.png
:align: center
:alt: Examples of Integer fields with different widgets
.. _studio/fields/simple-fields/decimal:
Decimal (`float`)
-----------------
The :guilabel:`Decimal` field is used for all decimal numbers (:dfn:`positive, negative, or zero,
with a decimal`).
.. note::
Decimal numbers are displayed with two decimals after the decimal point on the UI, but they are
stored in the database with more precision.
- :guilabel:`Monetary`: it is similar to using the :ref:`Monetary field
<studio/fields/simple-fields/monetary>`. It is recommended to use the later as it offers more
functionalities.
- :guilabel:`Percentage`: displays a percent character `%` after the value.
- :guilabel:`Percentage Pie`: displays the value inside a percentage circle, usually for a computed
value. The field cannot be edited manually, but a default value can be set.
- :guilabel:`Progress Bar`: displays the value next to a percentage bar, usually for a computed
value. The field cannot be edited manually, but a default value can be set.
- :guilabel:`Time`: the value must follow the *hh:mm* format, with a maximum of 59 minutes.
.. example::
.. image:: fields/decimal-examples.png
:align: center
:alt: Examples of Decimal fields with different widgets
.. _studio/fields/simple-fields/monetary:
Monetary (`monetary`)
---------------------
The :guilabel:`Monetary` field is used for all monetary values.
.. note::
When you first add a :guilabel:`Monetary` field, you are prompted to add a :guilabel:`Currency`
field if none exists already on the model. Odoo offers to add the :guilabel:`Currency` field for
you. Once it is added, add the :guilabel:`Monetary` field again.
.. example::
.. image:: fields/monetary-example.png
:align: center
:alt: Example of a Monetary field along with its Currency field
.. _studio/fields/simple-fields/html:
Html (`html`)
-------------
The :guilabel:`Html` field is used to add text that can be edited using the Odoo HTML editor.
- :guilabel:`Multiline Text`: disables the Odoo HTML editor to allow editing raw HTML.
.. example::
.. image:: fields/html-example.png
:align: center
:alt: Examples of Html fields with different widgets
.. _studio/fields/simple-fields/date:
Date (`date`)
-------------
The :guilabel:`Date` field is used to select a date on a calendar.
- :guilabel:`Remaining Days`: the remaining number of days before the selected date is displayed
(e.g., *In 5 days*), based on the current date.
.. example::
.. image:: fields/date-examples.png
:align: center
:alt: Examples of Date fields with different widgets
.. _studio/fields/simple-fields/date-time:
Date & Time (`datetime`)
------------------------
The :guilabel:`Date & Time` field is used to select a date on a calendar and a time on a clock. The
user's current time is automatically used if no time is set.
- :guilabel:`Date`: used to record the time without displaying it on the UI.
- :guilabel:`Remaining days`: displays the remaining number of days before the selected date (e.g.,
*In 5 days*), based on the current date and time.
.. example::
.. image:: fields/date-time-examples.png
:align: center
:alt: Examples of Date & Time fields with different widgets
.. _studio/fields/simple-fields/checkbox:
Checkbox (`boolean`)
--------------------
The :guilabel:`Checkbox` field is used when a value should only be true or false, indicated by
checking or unchecking a checkbox.
- :guilabel:`Button`: displays a radio button. The widget works without switching to the edit mode.
- :guilabel:`Toggle`: displays a toggle button. The widget works without switching to the edit mode.
.. example::
.. image:: fields/checkbox-examples.png
:align: center
:alt: Examples of Checkbox fields with different widgets
.. _studio/fields/simple-fields/selection:
Selection (`selection`)
-----------------------
The :guilabel:`Selection` field is used when users should select a single value from a group of
predefined values.
- :guilabel:`Badge`: displays the value inside a rounded shape, similar to a tag. The value cannot
be edited on the UI, but a default value can be set.
- :guilabel:`Badges`: displays all selectable values simultaneously inside rectangular shapes,
organized horizontally.
- :guilabel:`Priority`: displays star symbols instead of values, which can be used to indicate an
importance or satisfaction level, for example. This has the same effect as selecting the
:ref:`Priority field <studio/fields/simple-fields/priority>`, although, for the latter, four
priority values are already predefined.
- :guilabel:`Radio`: displays all selectable values at the same time as radio buttons.
.. tip::
By default, radio buttons are organized vertically. Tick :guilabel:`display horizontally` to
switch the way they are displayed.
.. example::
.. image:: fields/selection-examples.png
:align: center
:alt: Examples of Selection fields with different widgets
.. _studio/fields/simple-fields/priority:
Priority (`selection`)
----------------------
The :guilabel:`Priority` field is used to display a three-star rating system, which can be used to
indicate importance or satisfaction level. This field type is a :ref:`Selection field
<studio/fields/simple-fields/selection>` with the :guilabel:`Priority` widget selected by default
and four priority values predefined. Consequently, the :guilabel:`Badge`, :guilabel:`Badges`,
:guilabel:`Radio`, and :guilabel:`Selection` widgets have the same effects as described under
:ref:`Selection <studio/fields/simple-fields/selection>`.
.. tip::
To change the number of available stars by adding or removing values, click :guilabel:`Edit
Values`. Note that the first value is equal to 0 stars (i.e., when no selection is made), so
having four values results in a three-star rating system, for example.
.. example::
.. image:: fields/priority-example.png
:align: center
:alt: Example of a Priority field
.. _studio/fields/simple-fields/file:
File (`binary`)
---------------
The :guilabel:`File` field is used to upload any type of file, or sign a form (:guilabel:`Sign`
widget).
- :guilabel:`Image`: users can upload an image file, which is then displayed in :ref:`Form view
<studio/views/general/form>`. This has the same effect as using the :ref:`Image field
<studio/fields/simple-fields/image>`.
- :guilabel:`PDF Viewer`: users can upload a PDF file, which can be then browsed from the
:ref:`Form view <studio/views/general/form>`.
- :guilabel:`Sign`: users can electronically sign the form. This has the same effect as selecting
the :ref:`Sign field <studio/fields/simple-fields/sign>`.
.. example::
.. image:: fields/file-examples.png
:align: center
:alt: Examples of File fields with different widgets
.. _studio/fields/simple-fields/image:
Image (`binary`)
----------------
The :guilabel:`Image` field is used to upload an image and display it in :ref:`Form view
<studio/views/general/form>`. This field type is a :ref:`File field
<studio/fields/simple-fields/file>` with the :guilabel:`Image` widget selected by default.
Consequently, the :guilabel:`File`, :guilabel:`PDF Viewer`, and :guilabel:`Sign` widgets have the
same effects as described under :ref:`File <studio/fields/simple-fields/file>`.
.. tip::
To change the display size of uploaded images, select :guilabel:`Small`, :guilabel:`Medium`, or
:guilabel:`Large` under the :guilabel:`Size` option.
.. _studio/fields/simple-fields/sign:
Sign (`binary`)
---------------
The :guilabel:`Sign` field is used to sign the form electronically. This field type is a :ref:`File
field <studio/fields/simple-fields/file>` with the :guilabel:`Sign` widget selected by default.
Consequently, the :guilabel:`File`, :guilabel:`Image`, and :guilabel:`PDF Viewer` widgets have the
same effects as described under :ref:`File <studio/fields/simple-fields/file>`.
.. tip::
To give users the :guilabel:`Auto` option when having to draw their signature, select one of the
available :guilabel:`Auto-complete with` fields (:ref:`Text <studio/fields/simple-fields/text>`,
:ref:`Many2One <studio/fields/relational-fields/many2one>`, and :ref:`Related Field
<studio/fields/relational-fields/related-field>` on the model only). The signature is
automatically generated using the data from the selected field.
.. _studio/fields/relational-fields:
Relational fields
=================
Relational fields are used to link and display the data from records on another model.
.. note::
Non-default widgets, when available, are presented as bullet points below.
.. _studio/fields/relational-fields/many2one:
Many2One (`many2one`)
---------------------
The :guilabel:`Many2One` field is used to link another record (from another model) to the record
being edited. The record's name from the other model is then displayed on the record being edited.
.. example::
On the *Sales Order* model, the :guilabel:`Customer` field is a :guilabel:`Many2One` field
pointing at the *Contact* model. This allows **many** sales orders to be linked to **one**
contact (customer).
.. image:: fields/many2one-diagram.png
:align: center
:alt: Diagram showing a many2one relationship
.. tip::
- To prevent users from creating a new record in the linked model, tick :guilabel:`Disable
creation`.
- To prevent users from opening records in a pop-up window, tick :guilabel:`Disable opening`.
- To help users only select the right record, click on :guilabel:`Domain` to create a filter.
- :guilabel:`Badge`: displays the value inside a rounded shape, similar to a tag. The value cannot
be edited on the UI.
- :guilabel:`Radio`: displays all selectable values at the same time as radio buttons.
.. _studio/fields/relational-fields/one2many:
One2Many (`one2many`)
---------------------
The :guilabel:`One2Many` field is used to display the existing relations between a record on the
current model and multiple records from another model.
.. example::
You could add a :guilabel:`One2Many` field on the *Contact* model to look at **one** customer's
**many** sales orders.
.. image:: fields/one2many-diagram.png
:align: center
:alt: Diagram showing a one2many relationship
.. note::
To use a :guilabel:`One2Many` field, the two models must have been linked already using a
:ref:`Many2One field <studio/fields/relational-fields/many2one>`. One2Many relations do not exist
independently: a reverse-search of existing Many2One relations is performed.
.. _studio/fields/relational-fields/lines:
Lines (`one2many`)
------------------
The :guilabel:`Lines` field is used to create a table with rows and columns (e.g., the lines of
products on a sales order).
.. tip::
To modify the columns, click on the :guilabel:`Lines` field and then :guilabel:`Edit List View`.
To edit the form that pops up when a user clicks on :guilabel:`Add a line`, click on
:guilabel:`Edit Form View` instead.
.. example::
.. image:: fields/lines-example.png
:align: center
:alt: Example of a Lines field
.. _studio/fields/relational-fields/many2many:
Many2Many (`many2many`)
-----------------------
The :guilabel:`Many2Many` field is used to link multiple records from another model to multiple
records on the current model. Many2Many fields can use :guilabel:`Disable creation`,
:guilabel:`Disable opening`, :guilabel:`Domain`, just like :ref:`Many2One fields
<studio/fields/relational-fields/many2one>`.
.. example::
On the *Task* model, the :guilabel:`Assignees` field is a :guilabel:`Many2Many` field pointing at
the *Contact* model. This allows a single user to be assigned to **many** tasks and **many**
users to be assigned to a single task.
.. image:: fields/many2many-diagram.png
:align: center
:alt: Diagram showing many2many relationships
- :guilabel:`Checkboxes`: users can select several values using checkboxes.
- :guilabel:`Tags`: users can select several values appearing in rounded shapes, also known as
*tags*. This has the same effect as selecting the :ref:`Tags field
<studio/fields/relational-fields/tags>`.
.. _studio/fields/relational-fields/tags:
Tags (`many2many`)
------------------
The :guilabel:`Tags` field is used to display several values from another model appearing in rounded
shapes, also known as *tags*. This field type is a :ref:`Many2Many field
<studio/fields/relational-fields/many2many>` with the :guilabel:`Tags` widget selected by default.
Consequently, the :guilabel:`Checkboxes` and :guilabel:`Many2Many` widgets have the same effects as
described under :ref:`Many2Many <studio/fields/relational-fields/many2many>`.
.. tip::
To display tags with different background colors, tick :guilabel:`Use colors`.
.. example::
.. image:: fields/tags-example.png
:align: center
:alt: Example of a Tags field
.. _studio/fields/relational-fields/related-field:
Related Field (`related`)
-------------------------
A :guilabel:`Related Field` is not a relational field per se; no relationship is created between
models. It uses an existing relationship to fetch and display information from another record.
.. example::
To display the email address of a customer on the *Sales Order* model, use the :guilabel:`Related
Field` `partner_id.email` by selecting :guilabel:`Customer` and then :guilabel:`Email`.
.. _studio/fields/properties:
Properties
==========
- :guilabel:`Invisible`: When it is not necessary for users to view a field on the UI, tick
:guilabel:`Invisible`. It helps clear the UI by only showing the essential fields depending on a
specific situation.
.. example::
On the *Form* view of the *Contact* model, the :guilabel:`Title` field only appears when
:guilabel:`Individual` is selected, as that field would not be helpful for a
:guilabel:`Company` contact.
.. note::
The :guilabel:`Invisible` attribute also applies to Studio. To view hidden fields inside
Studio, click on a view's :guilabel:`View` tab and tick :guilabel:`Show Invisible
Elements`.
- :guilabel:`Required`: If a field should always be completed by the user before being able to
proceed, tick :guilabel:`Required`.
- :guilabel:`Read only`: If users should not be able to modify a field, tick :guilabel:`Read only`.
.. note::
You can choose to apply these three properties only for specific records by clicking on
:guilabel:`Conditional` and creating a filter.
- :guilabel:`Label`: The :guilabel:`Label` is the field's name on the UI.
.. note::
This is not the same name as used in the PostgreSQL database. To view and change the latter,
activate the :ref:`Developer mode <developer-mode>`, and edit the :guilabel:`Technical Name`.
- :guilabel:`Help Tooltip`: To explain the purpose of a field, write a description under
:guilabel:`Help Tooltip`. It is displayed inside a tooltip box when hovering with your mouse over
the field's label.
- :guilabel:`Placeholder`: To provide an example of how a field should be completed, write it under
:guilabel:`Placeholder`. It is displayed in light gray in lieu of the field's value.
- :guilabel:`Widget`: To change the default appearance or functionality of a field, select one of
the available widgets.
- :guilabel:`Default value`: To add a default value to a field when a record is created, use
:guilabel:`Default value`.
- :guilabel:`Limit visibility to groups`: To limit which users can see the field, select a user
access group.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,227 @@
=========================
Models, modules, and apps
=========================
Models determine the logical structure of a database and how data is stored, organized, and
manipulated. In other words, a model is a table of information that can be linked with other tables.
A model usually represents a business concept, such as a *sales order*, *contact*, or *product*.
Modules and apps contain various elements, such as models, views, data files, web controllers, and
static web data.
.. note::
All apps are modules. Larger, standalone modules are typically referred to as apps, whereas other
modules usually serve as add-ons to said apps.
.. _studio/models-modules-apps/suggested-features:
Suggested features
==================
When you create a new model or app with Studio, you can choose to add up to 14 features to speed
up the creation process. These features bundle fields, default settings, and views that are usually
used together to provide some standard functionality. Most of these features can be added later on,
but adding them from the start makes the model creation process much easier. Furthermore, these
features interact together in some cases to increase their usefulness.
.. example::
Creating a model with the :ref:`studio/models-modules-apps/suggested-features/picture` and
:ref:`studio/models-modules-apps/suggested-features/pipeline-stages` features enabled adds the
image in the card layout of the :ref:`Kanban view <studio/views/multiple-records/kanban>`.
.. image:: models_modules_apps/picture-pipeline-kanban.png
:align: center
:alt: Combination of the Picture and Pipeline stages features on the Kanban view
.. _studio/models-modules-apps/suggested-features/contact-details:
Contact details
---------------
Selecting :guilabel:`Contact details` adds to the :ref:`Form view <studio/views/general/form>` a
:ref:`Many2One field <studio/fields/relational-fields/many2one>` linked to the *Contact* model and
two of its :ref:`Related Fields <studio/fields/relational-fields/related-field>`: :guilabel:`Phone`
and :guilabel:`Email`. The :guilabel:`Contact` field is also added to the :ref:`List view
<studio/views/multiple-records/list>`, and the :ref:`Map view <studio/views/multiple-records/map>`
is activated.
.. example::
.. image:: models_modules_apps/contact.png
:align: center
:alt: Contact details feature on the Form view
.. _studio/models-modules-apps/suggested-features/user-assignment:
User assignment
---------------
Selecting :guilabel:`User assignment` adds to the :ref:`Form view <studio/views/general/form>` a
:ref:`Many2One field <studio/fields/relational-fields/many2one>` linked to the *Contact* model, with
the following :guilabel:`Domain`: `Share User is not set` to only allow the selection of *Internal
Users*. In addition, the :guilabel:`many2one_avatar_user` widget is used to display the user's
avatar. The :guilabel:`Responsible` field is also added to the :ref:`List view
<studio/views/multiple-records/list>`.
.. example::
.. image:: models_modules_apps/user-assignment.png
:align: center
:alt: User assignment feature on the Form view
.. _studio/models-modules-apps/suggested-features/date-calendar:
Date & Calendar
---------------
Selecting :guilabel:`Date & Calendar` adds to the :ref:`Form view <studio/views/general/form>` a
:ref:`Date field <studio/fields/simple-fields/date>` and activates the :ref:`Calendar view
<studio/views/timeline/calendar>`.
.. _studio/models-modules-apps/suggested-features/date-range-gantt:
Date range & Gantt
------------------
Selecting :guilabel:`Date range & Gantt` adds to the :ref:`Form view <studio/views/general/form>`
two :ref:`Date fields <studio/fields/simple-fields/date>` next to each other: one to set a start
date, the other to set an end date, using the :guilabel:`daterange` widget, and activates the
:ref:`Gantt view <studio/views/timeline/gantt>`.
.. _studio/models-modules-apps/suggested-features/pipeline-stages:
Pipeline stages
---------------
Selecting :guilabel:`Pipeline stages` activates the :ref:`Kanban view
<studio/views/multiple-records/kanban>`, adds several fields such as :ref:`Priority
<studio/fields/simple-fields/priority>` and :guilabel:`Kanban State`, and three stages:
:guilabel:`New`, :guilabel:`In Progress`, and :guilabel:`Done`. The :guilabel:`Pipeline status bar`
and the :guilabel:`Kanban State` field are added to the :ref:`Form view
<studio/views/general/form>`. The :guilabel:`Color` field is added to the :ref:`List view
<studio/views/multiple-records/list>`.
.. note::
The :guilabel:`Pipeline stages` feature can be added at a later stage.
.. _studio/models-modules-apps/suggested-features/tags:
Tags
----
Selecting :guilabel:`Tags` adds to the :ref:`studio/views/general/form` and
:ref:`studio/views/multiple-records/list` views a :ref:`Tags field
<studio/fields/relational-fields/tags>`, creating a *Tag* model with preconfigured access rights in
the process.
.. _studio/models-modules-apps/suggested-features/picture:
Picture
-------
Selecting :guilabel:`Picture` adds to the top-right of the :ref:`Form view
<studio/views/general/form>` an :ref:`Image field <studio/fields/simple-fields/image>`.
.. note::
The :guilabel:`Picture` feature can be added at a later stage.
.. _studio/models-modules-apps/suggested-features/lines:
Lines
-----
Selecting :guilabel:`Lines`: adds to the :ref:`Form view <studio/views/general/form>` a :ref:`Lines
field <studio/fields/relational-fields/lines>` inside a :guilabel:`Tab` component.
.. _studio/models-modules-apps/suggested-features/notes:
Notes
-----
Selecting :guilabel:`Notes` adds to the :ref:`Form view <studio/views/general/form>` an :ref:`Html
field <studio/fields/simple-fields/html>` using the full width of the form.
.. _studio/models-modules-apps/suggested-features/monetary-value:
Monetary value
--------------
Selecting :guilabel:`Monetary value` adds to the :ref:`studio/views/general/form` and
:ref:`studio/views/multiple-records/list` views a :ref:`Monetary field
<studio/fields/simple-fields/monetary>`. The :ref:`studio/views/reporting/graph` and
:ref:`studio/views/reporting/pivot` views are also activated.
.. note::
A *Currency* field is added and hidden from the view.
.. _studio/models-modules-apps/suggested-features/company:
Company
-------
Selecting :guilabel:`Company` adds to the :ref:`studio/views/general/form` and
:ref:`studio/views/multiple-records/list` views a :ref:`Many2One field
<studio/fields/relational-fields/many2one>` linked to the *Company* model.
.. note::
This is only useful if you work in a multi-company environment.
.. _studio/models-modules-apps/suggested-features/custom-sorting:
Custom Sorting
--------------
Selecting :guilabel:`Custom Sorting` adds to the :ref:`List view
<studio/views/multiple-records/list>` a drag handle icon to manually reorder records.
.. example::
.. image:: views/list-drag-handle.png
:align: center
:alt: Custom Sorting feature on the List view
.. _studio/models-modules-apps/suggested-features/chatter:
Chatter
-------
Selecting :guilabel:`Chatter` adds to the :ref:`Form view <studio/views/general/form>` Chatter
functionalities (sending messages, logging notes, and scheduling activities).
.. note::
The :guilabel:`Chatter` feature can be added at a later stage.
.. example::
.. image:: models_modules_apps/chatter.png
:align: center
:alt: Chatter feature on the Form view
.. _studio/models-modules-apps/suggested-features/archiving:
Archiving
---------
Selecting :guilabel:`Archiving` adds to the :ref:`studio/views/general/form` and
:ref:`studio/views/multiple-records/list` views the :guilabel:`Archive` action and hides archived
records from searches and views by default.
.. _studio/export-import:
Export and import customizations
================================
When you do any customization with Studio, a new module named :guilabel:`Studio customizations` is
added to your database.
To export these customizations, go to :menuselection:`Main dashboard --> Studio --> Customizations
--> Export` to download a ZIP file containing all customizations.
To import and install these customizations in another database, connect to the destination database
and go to :menuselection:`Main dashboard --> Studio --> Customizations --> Import`, then upload
the exported ZIP file before clicking on the :guilabel:`Import` button.
.. warning::
Before importing, make sure the destination database contains the same apps and modules as the
source database. Studio does not add the underlying modules as dependencies of the exported
module.
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

+571
View File
@@ -0,0 +1,571 @@
===========
PDF reports
===========
With Studio, you can :ref:`edit existing PDF reports <studio/pdf-reports/edit>` (e.g., invoices,
quotations, etc.) or :ref:`create new ones <studio/pdf-reports/edit>`.
.. _studio/pdf-reports/default-layout:
Default layout
==============
The default layout of reports is managed outside Studio. Go to :menuselection:`Settings`, then, in
the :guilabel:`Companies` section, click :guilabel:`Configure Document Layout`. Layout settings are
company-specific but apply to all reports.
.. tip::
You can see how the different settings affect the report layout in the report preview on the
right, or download a sample invoice PDF by clicking :guilabel:`Download PDF Preview`.
Use the following settings:
.. _studio/pdf-reports/default-layout/layout:
- :guilabel:`Layout`: Four layouts are available:
.. tabs::
.. tab:: Light
.. image:: pdf_reports/layout-light.png
:alt: Light report layout sample
.. tab:: Boxed
.. image:: pdf_reports/layout-boxed.png
:alt: Boxed report layout sample
.. tab:: Bold
.. image:: pdf_reports/layout-bold.png
:alt: Bold report layout sample
.. tab:: Striped
.. image:: pdf_reports/layout-striped.png
:alt: Striped report layout sample
.. _studio/pdf-reports/default-layout/font:
- :guilabel:`Font`: Seven fonts are available: Lato, Roboto, Open Sans, Montserrat, Oswald, Raleway,
and Tajawal (which supports Arabic and Latin scripts). Go to the
`Google Fonts website <https://fonts.google.com/>`_ to preview them.
.. _studio/pdf-reports/default-layout/logo:
- :guilabel:`Company logo`: Click the :guilabel:`Edit` button to upload or change the logo. This
adds the logo to the companys record on the *Company* model, which you can access by going to
:menuselection:`Settings` and then clicking :guilabel:`Update Info` in the :guilabel:`Companies`
section.
.. _studio/pdf-reports/default-layout/colors:
- :guilabel:`Colors`: Change the primary and secondary colors used to structure reports. The default
colors are automatically generated based on the colors of the logo.
.. _studio/pdf-reports/default-layout/background:
- :guilabel:`Layout background`: The following backgrounds are available:
- :guilabel:`Blank`: nothing is displayed.
- :guilabel:`Geometric`: an image featuring geometric shapes is displayed in the background.
- :guilabel:`Custom`: upload a custom background image.
.. _studio/pdf-reports/default-layout/tagline:
- :guilabel:`Company tagline`: This is displayed in the header of :ref:`external reports
<studio/pdf-reports/header-footer/external>`. You can add multiple lines of text.
.. _studio/pdf-reports/default-layout/details:
- :guilabel:`Company details`: These are displayed in the header of :ref:`external reports
<studio/pdf-reports/header-footer/external>`. You can add multiple lines of text.
.. _studio/pdf-reports/default-layout/footer:
- :guilabel:`Footer`: This text is used in the footer of :ref:`external reports
<studio/pdf-reports/header-footer/external>`. You can add multiple lines of text. You can also
edit the footer using the :ref:`report editor <studio/pdf-reports/edit>`.
.. _studio/pdf-reports/default-layout/paper:
- :guilabel:`Paper format`: to define the default paper size of reports. You can select
:guilabel:`A4` (21 cm x 29.7 cm), :guilabel:`US Letter` (21.59 cm x 27.54 cm), or
:guilabel:`QR codes page`. This can also be defined for individual reports in the
:guilabel:`Paper format` field in :ref:`Studio <studio/pdf-reports/create>`.
.. _studio/pdf-reports/create:
Creating new PDF reports
========================
To create a new report for a model, access the model, click the **Toggle Studio** button, then click
:guilabel:`Reports`. Click :guilabel:`New` and, in the popup window that opens, select the type of
report. This is solely used to determine what is displayed in the header and footer:
.. _studio/pdf-reports/header-footer/external:
- :guilabel:`External`:
- The header displays the company's :ref:`logo <studio/pdf-reports/default-layout/logo>`,
:ref:`tagline <studio/pdf-reports/default-layout/tagline>`, and
:ref:`details <studio/pdf-reports/default-layout/details>`.
- The footer displays the values set in the
:ref:`Footer <studio/pdf-reports/default-layout/footer>` field and the page number.
- :guilabel:`Internal`: The header displays the user's current date and time,
:guilabel:`Company Name`, and page number. There is no footer.
- :guilabel:`Blank`: There is neither a header nor a footer. Click in the upper left corner of the
page to edit the report.
Once you have created the report, you can start :ref:`editing it <studio/pdf-reports/edit>`.
.. _studio/pdf-reports/edit:
Editing PDF reports
===================
To access the reports available for a model, access the model (e.g., sales orders), click the
**Toggle Studio** button, then click :guilabel:`Reports`. Select an existing report to open it or
:ref:`create a new one <studio/pdf-reports/create>`.
.. tip::
Alternatively, you can also open Studio, click :guilabel:`Reports`, and search for a specific
report or model.
.. important::
It is strongly recommended to **duplicate** the standard report and perform changes in the
duplicated version. To duplicate a report, hover the mouse pointer on the top right corner
of the report, click the vertical ellipsis icon (:guilabel:`⋮`), and then select
:guilabel:`Duplicate`.
.. image:: pdf_reports/duplicate-report.png
:alt: Duplicating a PDF report
Options
-------
Once you've selected or created a report, you can use the options in the left part of the screen to:
- Change the :guilabel:`Report name`. The new name is applied everywhere (in Studio, under
the :guilabel:`Print` button, and in the PDF file name).
- Modify the :guilabel:`Paper format`. If no value is selected, the format defined in the
:ref:`default layout <studio/pdf-reports/default-layout/paper>` is used.
- :guilabel:`Show in print menu`: to add the report in the :guilabel:`Print` menu available from the
record.
- :guilabel:`Reload from attachment`: to save the report as an attachment on the record the first
time it is generated and reload the original version of the report any subsequent time. This is
legally required for invoices and is mainly used in this case.
- :guilabel:`Limit visibility to groups`: to limit the availability of the PDF report to specific
:doc:`user groups <../general/users/access_rights>`.
- :guilabel:`Edit sources`: to modify the report directly in the :ref:`XML file
<studio/pdf-reports/XML-editing>`.
- :guilabel:`Reset report`: to discard all changes made to the report and reset it to its standard
version.
- :guilabel:`Print preview`: to generate and download a report preview.
Report editor
-------------
The report editor allows you to modify the formatting and contents of the report.
.. tip::
- You can :guilabel:`Undo` or :guilabel:`Redo` changes using the related buttons or the shortcuts
`CTRL Z` and `CTRL Y`.
- Changes are saved automatically when you leave the report or manually using the
:guilabel:`Save` button.
- You can reset the report to its standard version by clicking the :guilabel:`Reset report` button
in the left part of the screen.
.. important::
Editing the header and footer of a report impacts all standard and custom reports.
Conditional blocks
~~~~~~~~~~~~~~~~~~
The dashed rectangles represent **conditional blocks** (*if/else* statements). These are used to
show/hide content based on specific conditions. Click on the block to view the conditions.
.. image:: pdf_reports/conditional-block-if.png
:alt: View conditions applied to a block.
Select a value to preview its corresponding output and edit it if necessary.
.. image:: pdf_reports/conditional-block-else.png
:alt: Preview the output of another condition.
.. note::
Conditions can only be edited in :ref:`XML <studio/pdf-reports/XML-editing>`.
Other content
~~~~~~~~~~~~~
There are two types of text content in reports:
- Static text, i.e., the text that's not highlighted in blue, which can be modified directly in the
editor.
- Dynamic text, i.e., the text that's highlighted in blue, which is replaced by field values when
the report is generated, e.g., the SO number or the quotation date.
You can add content (e.g., fields, lists, tables, images, banners, etc.) to the report using
commands. Type `/` to open the :ref:`powerbox <knowledge/powerbox>`, then type the command's
name or select it from the list.
To add static text to the report, type the text where you want it.
For more advanced changes, you can :ref:`edit the report in the XML directly
<studio/pdf-reports/XML-editing>`.
.. _studio/pdf-reports/add-field:
Add a field
***********
To add a field, type `/` and select the :guilabel:`Field` command. In the list that opens, select
or search for the field; click the right arrow next to the field name to access the list of related
fields if needed. Then, specify the default value and press `Enter`.
.. image:: pdf_reports/powerbox-field.png
:alt: Select a related field.
Add a data table
****************
Data tables are used to display :ref:`relational fields <studio/fields/relational-fields>`. To add
a data table, type `/`, select the :guilabel:`Dynamic Table` command, and select the relation to be
displayed in the table.
.. note::
Only relations of type `one2many` or `many2many` can be displayed as data tables.
Once the table has been added, you can add columns using the table tools. Position the cursor on top
of the column, then click the purple rectangle and select an option.
.. image:: pdf_reports/table-add-column.png
:alt: Add a column in a dynamic table.
You can then insert the :ref:`field of your choice
<studio/pdf-reports/add-field>` in the columns. The dialog box that opens shows the source object
for the field (e.g., the *Tag* model) and the list of available fields.
.. image:: pdf_reports/dynamic-table.png
:alt: List of available fields for the Tag model.
.. note::
- The default row automatically iterates over the field's content, generating a row on the report
for each field value (e.g., one row per tag). You can add static content rows above or below
the generated rows using the table tools.
- You can also add data tables by :ref:`modifying the report's XML <studio/pdf-reports/XML-editing>`.
Formatting
**********
To format text in the report, select it, then format it using the options in the
:ref:`knowledge/text-editor`.
.. image:: pdf_reports/text-editor.png
:alt: Format text using the text editor.
.. _studio/pdf-reports/XML-editing:
Editing the report's XML
------------------------
.. warning::
Modifying the XML directly may result in report issues during :doc:`upgrades
<../../../administration/upgrade>`. If this happens, simply copy your changes from the old
database into your upgraded database.
To edit the report's XML, click :guilabel:`Edit sources` in the left pane.
Examples
~~~~~~~~
.. spoiler:: Modify a non-compliant table
Sometimes, tables are not properly recognized as such due to complex structures. In those cases,
you can still modify them manually in the report XML. For example, with a sales order, you can
find the following structure in the XML (simplified for documentation purposes):
.. code-block:: xml
<!-- table root element -->
<table>
<!-- thead = table header, the row with column titles -->
<thead>
<!-- table row element -->
<tr>
<!-- table header element -->
<th>Name</th>
<th>Price</th>
</tr>
</thead>
<!-- table body, the main content -->
<tbody>
<!-- we create a row for each subrecord with t-foreach -->
<tr t-foreach="record.some_relation_ids" t-as="line">
<!-- for each line, we output the name and price as table cells -->
<td t-out="line.name"/>
<td t-out="line.price"/>
</tr>
</tbody>
</table>
To modify a table, you must ensure that each row has the same number of data cells. For example,
in the case above, you need to add a cell in the header section (with e.g., the column title)
and another one in the body section with the field content (usually, with a `t-out` or
`t-field` directive).
.. code-block:: xml
:emphasize-lines: 6,13
<table> <!-- table root element -->
<thead> <!-- thead = table header, the row with column titles -->
<tr> <!-- table row element -->
<th>Name</th> <!-- table header element -->
<th>Price</th>
<th>Category</th>
</tr>
</thead>
<tbody> <!-- table body, the main content -->
<tr t-foreach="record.some_relation_ids" t-as="line"> <!-- we create a row for each subrecord with t-foreach -->
<td t-out="line.name"/> <!-- for each line, we output the name and price as table cells -->
<td t-out="line.price"/>
<td t-out="line.category_id.display_name"/>
</tr>
</tbody>
</table>
.. note::
Cells can span multiple rows or columns. For more information, go to the
`Mozilla Developer Network website <https://developer.mozilla.org/en-US/docs/Learn/HTML/Tables/Basics>`_.
For example, you can modify the **Quotation/Order** report to add a column to display the
product category in the main table:
.. code-block:: xml
:emphasize-lines: 6,13
<table class="table table-sm o_main_table table-borderless mt-4">
<!-- In case we want to repeat the header, remove "display: table-row-group" -->
<thead style="display: table-row-group">
<tr>
<th name="th_description" class="text-start">Description</th>
<th>Product Category</th>
<th name="th_quantity" class="text-end">Quantity</th>
<th name="th_priceunit" class="text-end">Unit Price</th>
[...]
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="not line.display_type">
<td name="td_name"><span t-field="line.name">Bacon Burger</span></td>
<td t-out="line.product_id.categ_id.display_name"/>
<td name="td_quantity" class="text-end">
<span t-field="line.product_uom_qty">3</span>
<span t-field="line.product_uom">units</span>
<span t-if="line.product_packaging_id">
.. image:: pdf_reports/XML-SO-product-category.png
:alt: Add a Product Category column in a SO.
.. spoiler:: Add a data table
To add a table in XML, you need to know the names of the fields and objects you wish to access
and display. As an example, let's add a table that details the tags on a sales order:
.. code-block:: xml
<!-- table root element -->
<table class="table">
<!-- thead = table header, the row with column titles -->
<thead>
<!-- table row element -->
<tr>
<!-- table header element -->
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<!-- table body, the main content -->
<tbody>
<!-- we create a row for each subrecord with t-foreach -->
<tr t-foreach="doc.tag_ids" t-as="tag">
<!-- for each line, we output the name and price as table cells -->
<td t-out="tag.id"/>
<td t-out="tag.name"/>
</tr>
</tbody>
</table>
.. image:: pdf_reports/XML-data-table.png
:alt: Add a data table in XML
.. note::
When adding tables manually, style them using `Bootstrap classes
<https://getbootstrap.com/docs/5.1/content/tables>`_, like the `table` class included in the
example above.
.. spoiler:: Conditional blocks
If you want to show/hide content based on specific conditions, you can manually add `if/else`
control statements in the report XML.
For example, if you want to hide a custom data table if there are no tags, you can use the `t-if`
attribute to define the condition, which is then evaluated as `True` or `False`. The table will
not be displayed if there are no tags in the quotation.
.. code-block:: xml
:emphasize-lines: 2
<!-- table root element -->
<table class="table" t-if="len(doc.tag_ids) > 0">
<!-- thead = table header, the row with column titles -->
<thead>
<!-- table row element -->
<tr>
<!-- table header element -->
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<!-- table body, the main content -->
<tbody>
<!-- we create a row for each subrecord with t-foreach -->
<tr t-foreach="doc.tag_ids" t-as="tag">
<!-- for each line, we output the name and price as table cells -->
<td t-out="tag.id"/>
<td t-out="tag.name"/>
</tr>
</tbody>
</table>
If you want to display another block in case the `t-if` statement is evaluated as `False`, you
can specify it using the `t-else` statement. The `t-else` block must directly follow the `t-if`
block in the document structure. There is no need to specify any condition in the `t-else`
attribute. As an example, let's show a quick message explaining that there are no tags on the
quotation:
.. code-block:: xml
:emphasize-lines: 22
<!-- table root element -->
<table class="table" t-if="len(doc.tag_ids) > 0">
<!-- thead = table header, the row with column titles -->
<thead>
<!-- table row element -->
<tr>
<!-- table header element -->
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<!-- table body, the main content -->
<tbody>
<!-- we create a row for each subrecord with t-foreach -->
<tr t-foreach="doc.tag_ids" t-as="tag">
<!-- for each line, we output the name and price as table cells -->
<td t-out="tag.id"/>
<td t-out="tag.name"/>
</tr>
</tbody>
</table>
<div class="text-muted" t-else="">No tag present on this document.</div>
By using the `t-if/t-else` notation, the report editor recognizes that these sections are
mutually exclusive and should be displayed as conditional blocks:
.. image:: pdf_reports/XML-condition-if.png
:alt: Output preview if there are tags.
You can switch conditions using the editor to preview their output:
.. image:: pdf_reports/XML-condition-else.png
:alt: Output preview if there are no tags.
If you wish to have multiple options, you can also use `t-elif` directives to add intermediary
conditions. For example, this is how the title of sales order reports changes based on the
condition of the underlying document.
.. code-block:: xml
<h2 class="mt-4">
<span t-if="env.context.get('proforma', False) or is_pro_forma">Pro-Forma Invoice # </span>
<span t-elif="doc.state in ['draft','sent']">Quotation # </span>
<span t-else="">Order # </span>
<span t-field="doc.name">SO0000</span>
</h2>
The title *Pro-Forma Invoice* is used depending on some contextual conditions. If these
conditions are not met and the state of the document is either `draft` or `sent`, then
*Quotation* is used. If none of those conditions are met, the report's title is *Order*.
.. spoiler:: Images
Working with images in a report can be challenging, as precise control over image size and
behavior is not always obvious. You can insert image fields using the report editor
(:ref:`by using the /Field command <studio/pdf-reports/add-field>`), but inserting them in XML
using the `t-field` directive and accompanying `t-options` attributes provides better sizing and
positioning control.
For example, the following code outputs the field `image_128` of the line's product as a
64px-wide image (with an automatic height based on the image's aspect ratio).
.. code-block:: xml
<span t-field="line.product_id.image_128" t-options-widget="image" t-options-width="64px"/>
The following options are available for image widgets:
- `width`: width of the image, usually in pixels or CSS length units (e.g., `rem`) (leave empty
for auto-width).
- `height`: height of the image, usually in pixels or CSS length units (e.g., `rem`) (leave empty
for auto-height).
- `class`: CSS classes applied on the `img` tag; `Bootstrap classes
<https://getbootstrap.com/docs/5.1/content/tables>`_ are available.
- `alt`: alternative text of the image
- `style`: style attribute; it allows you to override styles more freely than with
`Bootstrap classes <https://getbootstrap.com/docs/5.1/content/tables>`_.
These attributes must contain strings, i.e., text enclosed within quotes within quotes, e.g.,
`t-options-width="'64px'"` (or, alternatively, a valid Python expression).
.. note::
The image widget cannot be used on an `img` tag. Instead, set the `t-field` directive on a
`span` (for inline content) or `div` (for block content) node.
For example, let's add a column with the product image in the quotation table:
.. code-block:: xml
:emphasize-lines: 4,14-20
<table class="table table-sm o_main_table table-borderless mt-4">
<thead style="display: table-row-group">
<tr>
<th>Image</th>
<th name="th_description" class="text-start">Description</th>
<th>Product Category</th>
<th name="th_quantity" class="text-end">Quantity</th>
<th name="th_priceunit" class="text-end">Unit Price</th>
[...]
<t t-foreach="lines_to_report" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="not line.display_type">
<td>
<span t-field="line.product_template_id.image_128"
t-options-widget="'image'"
t-options-width="'64px'"
t-options-class="'rounded-3 shadow img-thumbnail'"
/>
</td>
<td name="td_name"><span t-field="line.name">Bacon Burger</span></td>
<td t-out="line.product_id.categ_id.display_name"/>
The `t-options-width` attribute restricts the image width to 64 pixels, and the Bootstrap classes
used in `t-options-class` create a thumbnail-like border with rounded corners and a shadow.
.. image:: pdf_reports/XML-images.png
:alt: Add a column with the product image in the quotation table.
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

+378
View File
@@ -0,0 +1,378 @@
=====
Views
=====
Views are the interface that allows displaying the data contained in a model. One model can have
several views, which are simply different ways to show the same data. In Studio, views are organized
into four categories: :ref:`general <studio/views/general>`, :ref:`multiple records
<studio/views/multiple-records>`, :ref:`timeline <studio/views/timeline>`, and :ref:`reporting
<studio/views/reporting>`.
.. tip::
To change the default view of a model, go to :menuselection:`Studio --> Views --> Dropdown menu
(⋮) --> Set as Default`.
.. note::
You can modify views by using the built-in XML editor. To do so, activate :ref:`Developer mode
<developer-mode>`, go to the view you want to edit, select the :guilabel:`View` tab and then
click on :guilabel:`</> XML`.
.. important::
If you are editing a view using the XML editor, avoid making changes directly to standard
views and inherited views, as those would be reset and would not be kept in case of an update
or module upgrade. Always make sure you select the right Studio inherited views. Indeed, when
you modify a view in Studio by drag-and-dropping a new field, a specific Studio inherited view
and its XPath, the latter which defines which part of the view is modified, are automatically
generated.
.. _studio/views/general:
General views
=============
.. note::
The settings described below are found under the view's :guilabel:`View` tab unless specified
otherwise.
.. _studio/views/general/form:
Form
----
The :guilabel:`Form` view is used when creating and editing records, such as contacts, sales orders,
products, etc.
- To structure a form, drag-and-drop the :guilabel:`Tabs and Columns` element found under the
:guilabel:`+ Add` tab.
- To prevent users from creating, editing, or deleting records, untick :guilabel:`Can Create`,
:guilabel:`Can Edit`, or :guilabel:`Can Delete`.
.. example::
.. image:: views/form-sales-order.png
:align: center
:alt: Sales order model's Form view
.. _studio/views/general/activity:
Activity
--------
The :guilabel:`Activity` view is used to schedule and have an overview of activities (emails, calls,
etc.) linked to records.
.. note::
This view can only be modified within Studio by editing the XML code.
.. example::
.. image:: views/activity-lead-opportunity.png
:align: center
:alt: Lead/Opportunity model's Activity view
.. _studio/views/general/search:
Search
------
The :guilabel:`Search` view is added on top of other views to filter, group, and search records.
- To add custom :guilabel:`Filters` and structure them using :guilabel:`Separators`, go to the
:guilabel:`+ Add` tab and drag and drop them under :guilabel:`Filters`.
- To add an existing field under the search dropdown menu, go to the :guilabel:`+ Add` tab and
drag-and-drop it under :guilabel:`Autocompletion Fields`.
.. example::
.. image:: views/search-project-kanban.png
:align: center
:alt: Project model's Search view on the Kanban view
.. _studio/views/multiple-records:
Multiple records views
======================
.. note::
The settings described below are found under the view's :guilabel:`View` tab unless specified
otherwise.
.. _studio/views/multiple-records/kanban:
Kanban
------
The :guilabel:`Kanban` view is often used to support business flows by moving records across stages
or as an alternative way to display records inside *cards*.
.. note::
If the :guilabel:`Kanban` view exists, it is used by default to display data on mobile devices
instead of the :ref:`List view <studio/views/multiple-records/list>`.
- To prevent users from creating new records, untick :guilabel:`Can Create`.
- To create records directly within the view, in a minimalistic form, enable :guilabel:`Quick
Create`.
- To change the way records are grouped by default, select a new group under :guilabel:`Default
Group by`.
.. example::
.. image:: views/kanban-project.png
:align: center
:alt: Project model's Kanban view
.. _studio/views/multiple-records/list:
List
----
The :guilabel:`List` view is used to overview many records at once, look for records, and edit
simple records.
- To prevent users from creating, editing, or deleting records, untick :guilabel:`Can Create`,
:guilabel:`Can Edit`, or :guilabel:`Can Delete`.
- To create and edit records directly within the view, select either :guilabel:`New record on top`
or :guilabel:`New record at the bottom` under :guilabel:`Editable`.
.. note::
This prevents users from opening records in :ref:`Form view <studio/views/general/form>` from the
:guilabel:`List` view.
- To edit several records at once, tick :guilabel:`Enable Mass Editing`.
- To change the way records are sorted by default, select a field under :guilabel:`Sort By`.
.. tip::
To add a drag handle icon to reorder records manually, add an :ref:`Integer field
<studio/fields/simple-fields/integer>` with the :guilabel:`Handle` widget.
.. image:: views/list-drag-handle.png
:align: center
:alt: Drag handle icon enabling to sort records manually in List view
.. example::
.. image:: views/list-sales-order.png
:align: center
:alt: Sales order model's List view
.. _studio/views/multiple-records/map:
Map
---
The :guilabel:`Map` view is used to display records on a map. For example, it is used in the Field
Service app to plan an itinerary between different tasks.
.. note::
A :ref:`Many2One field <studio/fields/relational-fields/many2one>` linked to the *Contact* model
is required to activate the view, as the contact address is used to position records on the map.
- To select which kind of contact should be used on the map, select it under :guilabel:`Contact
Field`.
- To hide the name or the address of the record, tick :guilabel:`Hide name` or :guilabel:`Hide
Address`.
- To add information from other fields, select them under :guilabel:`Additional Fields`.
- To have a route suggested between the different records, tick :guilabel:`Enable Routing` and
select which field should be used to sort records for the routing.
.. example::
.. image:: views/map-task.png
:align: center
:alt: Task model's Map view
.. _studio/views/timeline:
Timeline views
==============
.. note::
- When you first activate one of the timeline views, you need to select which :ref:`Date
<studio/fields/simple-fields/date>` or :ref:`Date & Time
<studio/fields/simple-fields/date-time>` fields on your model should be used to define when the
records start and stop in order to display them on the view. You can modify the
:guilabel:`Start Date Field` and :guilabel:`Stop Date Field` after activating the view.
- The settings described below are found under the view's :guilabel:`View` tab unless specified
otherwise.
.. _studio/views/timeline/calendar:
Calendar
--------
The :guilabel:`Calendar` view is used to overview and manage records inside a calendar.
- To create records directly within the view instead of opening the :ref:`Form view
<studio/views/general/form>`, enable :guilabel:`Quick Create`.
.. note::
This only works on specific models that can be *quick-created* using only a *name*. However,
most models do not support quick creation and open the :guilabel:`Form` view to fill in the
required fields.
- To color records on the calendar, select a field under :guilabel:`Color`. All the records sharing
the same value for that field are displayed using the same color.
.. note::
As the number of colors is limited, the same color can end up being assigned to different
values.
- To display events lasting the whole day at the top of the calendar, select a :ref:`Checkbox field
<studio/fields/simple-fields/checkbox>` that specifies if the event lasts the whole day.
- To choose the default time scale used to display events, select :guilabel:`Day`, :guilabel:`Week`,
:guilabel:`Month`, or :guilabel:`Year` under :guilabel:`Default Display Mode`.
.. note::
You can also use :guilabel:`Delay Field` to display the duration of the event in hours by
selecting a :ref:`Decimal <studio/fields/simple-fields/decimal>` or :ref:`Integer
<studio/fields/simple-fields/integer>` field on the model which specifies the duration of the
event. However, if you set an :guilabel:`End Date Field`, the :guilabel:`Delay Field` will not be
taken into account.
.. example::
.. image:: views/calendar-event.png
:align: center
:alt: Calendar Event model's Calendar view
.. _studio/views/timeline/cohort:
Cohort
------
The :guilabel:`Cohort` view is used to examine the life cycle of records over a time period. For
example, it is used in the Subscriptions app to view the subscriptions' retention rate.
- To display a measure (i.e., the aggregated value of a given field) by default on the view, select
a :guilabel:`Measure Field`.
- To choose which time interval is used by default to group results, select :guilabel:`Day`,
:guilabel:`Week`, :guilabel:`Month`, or :guilabel:`Year` under :guilabel:`Interval`.
- To change the cohort :guilabel:`Mode`, select either :guilabel:`Retention` :dfn:`the percentage
of records staying over a period of time, it starts at 100% and decreases with time` or
:guilabel:`Churn` :dfn:`the percentage of records moving out over a period of time - it starts at
0% and increases with time`.
- To change the way the :guilabel:`Timeline` (i.e., the columns) progresses, select either
:guilabel:`Forward` (from 0 to +15) or :guilabel:`Backward` (from -15 to 0). For most purposes,
the :guilabel:`Forward` timeline is used.
.. example::
.. image:: views/cohort-subscription.png
:align: center
:alt: Subscription model's Cohort view
.. _studio/views/timeline/gantt:
Gantt
-----
The :guilabel:`Gantt` view is used to forecast and examine the overall progress of records. Records
are represented by a bar under a time scale.
- To prevent users from creating or editing records, untick :guilabel:`Can Create` or :guilabel:`Can
Edit`.
- To fill cells in gray whenever a record should not be created there (e.g., on weekends for
employees), tick :guilabel:`Display Unavailability`.
.. note::
The underlying model must support this feature, and support for it cannot be added using
Studio. It is supported for the Project, Time Off, Planning, and Manufacturing apps.
- To show a total row at the bottom, tick :guilabel:`Display Total row`.
- To collapse multiple records in a single row, tick :guilabel:`Collapse First Level`.
- To choose which way records are grouped by default on rows (e.g., per employee or project), select
a field under :guilabel:`Default Group by`.
- To define a default time scale to view records, select :guilabel:`Day`, :guilabel:`Week`,
:guilabel:`Month`, or :guilabel:`Year` under :guilabel:`Default Scale`.
- To color records on the view, select a field under :guilabel:`Color`. All the records sharing the
same value for that field are displayed using the same color.
.. note::
As the number of colors is limited, the same color can be assigned to different values.
- To specify with which degree of precision each time scale should be divided by, select
:guilabel:`Quarter Hour`, :guilabel:`Half Hour`, or :guilabel:`Hour` under :guilabel:`Day
Precision`, :guilabel:`Half Day` or :guilabel:`Day` under :guilabel:`Week Precision`, and
:guilabel:`Month Precision`.
.. example::
.. image:: views/gantt-planning.png
:align: center
:alt: Planning Shift model's Gantt view
.. _studio/views/reporting:
Reporting views
===============
.. note::
The settings described below are found under the view's :guilabel:`View` tab unless specified
otherwise.
.. _studio/views/reporting/pivot:
Pivot
-----
The :guilabel:`Pivot` view is used to explore and analyze the data contained in records in an
interactive manner. It is especially useful to aggregate numeric data, create categories, and drill
down the data by expanding and collapsing different levels of data.
- To access all records whose data is aggregated under a cell, tick :guilabel:`Access records from
cell`.
- To divide the data into different categories, select field(s) under :guilabel:`Column grouping`,
:guilabel:`Row grouping - First level`, or :guilabel:`Row grouping - Second level`.
- To add different types of data to be measured using the view, select a field under
:guilabel:`Measures`.
- To display a count of records that made up the aggregated data in a cell, tick :guilabel:`Display
count`.
.. example::
.. image:: views/pivot-purchase-report.png
:align: center
:alt: Purchase Report model's Pivot view
.. _studio/views/reporting/graph:
Graph
-----
The :guilabel:`Graph` view is used to showcase data from records in a bar, line, or pie chart.
- To change the default chart, select :guilabel:`Bar`, :guilabel:`Line`, or :guilabel:`Pie` under
:guilabel:`Type`.
- To choose a default data dimension (category), select a field under :guilabel:`First dimension`
and, if needed, another under :guilabel:`Second dimension`.
- To select a default type of data to be measured using the view, select a field under
:guilabel:`Measure`.
- *For Bar and Line charts only*: To sort the different data categories by their value, select
:guilabel:`Ascending` (from lowest to highest value) or :guilabel:`Descending` (from highest to
lowest) under :guilabel:`Sorting`.
- *For Bar and Pie charts only*: To access all records whose data is aggregated under a data
category on the chart, tick :guilabel:`Access records from graph`.
- *For Bar charts only*: When using two data dimensions (categories), display the two columns on top
of each other by default by ticking :guilabel:`Stacked graph`.
.. example::
.. image:: views/graph-sales-report.png
:align: center
:alt: Sales Analysis Report model's Bar chart on Graph view
.. _studio/views/reporting/dashboard:
Dashboard
---------
The :guilabel:`Dashboard` view is used to display multiple reporting views and key performance
indicators. Which elements are displayed on the view depends on the configuration of the other
reporting views.
.. example::
.. image:: views/dashboard-sales-report.png
:align: center
:alt: Sales Analysis Report model's Dashboard view
Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB