[IMP] developer/../view_architectures: new control
feature
This commit updates the documentation related to the `control` feature of list and kanban views, w.r.t. to recent changes on that matter. Linked to odoo/odoo#188619 task~4063960 closes odoo/documentation#11536 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
parent
989d5b1110
commit
366f1d4735
@ -1648,11 +1648,16 @@ The `header` element accepts the following children elements:
|
|||||||
|
|
||||||
.. _reference/view_architectures/list/control:
|
.. _reference/view_architectures/list/control:
|
||||||
|
|
||||||
`control` & `create`: add inline create buttons
|
`control`: customize create and delete actions
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
The `control` element defines a control row that accepts create buttons. Each create button is
|
The `control` element allows to customize the create and delete actions. In particular, it allows
|
||||||
defined through a `create` element.
|
to add special create buttons with specific contexts, to use regular view buttons as create
|
||||||
|
actions, and to make the create and delete actions available only under certain conditions.
|
||||||
|
|
||||||
|
.. important::
|
||||||
|
The `control` element is only supported in list views inside :class:`~odoo.fields.One2many` or
|
||||||
|
:class:`~odoo.fields.Many2many` fields.
|
||||||
|
|
||||||
.. code-block:: xml
|
.. code-block:: xml
|
||||||
|
|
||||||
@ -1660,13 +1665,18 @@ defined through a `create` element.
|
|||||||
<control>
|
<control>
|
||||||
<create string="LABEL"/>
|
<create string="LABEL"/>
|
||||||
<BUTTONS/>
|
<BUTTONS/>
|
||||||
|
<delete invisible="parent.is_sent">
|
||||||
</control>
|
</control>
|
||||||
...
|
...
|
||||||
</list>
|
</list>
|
||||||
|
|
||||||
The `control` element takes no attributes.
|
The `control` element takes no attributes. It accepts the following children elements:
|
||||||
|
|
||||||
The `create` element can have the following attributes:
|
.. attribute:: create
|
||||||
|
:noindex:
|
||||||
|
|
||||||
|
The given `create` elements replace the default :guilabel:`Add a line` button.
|
||||||
|
A `create` element can have the following attributes:
|
||||||
|
|
||||||
.. attribute:: string
|
.. attribute:: string
|
||||||
:noindex:
|
:noindex:
|
||||||
@ -1686,6 +1696,32 @@ The `create` element can have the following attributes:
|
|||||||
:type: :ref:`Python expression <reference/view_architectures/python_expression>`
|
:type: :ref:`Python expression <reference/view_architectures/python_expression>`
|
||||||
:default: `{}`
|
:default: `{}`
|
||||||
|
|
||||||
|
.. attribute:: invisible
|
||||||
|
:noindex:
|
||||||
|
|
||||||
|
Whether the element is visible (`False`) or hidden (`True`), as a Python expression that evaluates to a
|
||||||
|
bool. The parent record and the context can be used in the expresion.
|
||||||
|
|
||||||
|
:requirement: Optional
|
||||||
|
:type: :ref:`Python expression <reference/view_architectures/python_expression>`
|
||||||
|
:default: `False`
|
||||||
|
|
||||||
|
.. attribute:: button
|
||||||
|
:noindex:
|
||||||
|
|
||||||
|
Like :ref:`regular view buttons <reference/view_architectures/list/button>`
|
||||||
|
|
||||||
|
.. attribute:: delete
|
||||||
|
|
||||||
|
The `delete` element allows to conditionnaly hide the delete icon, row by row. There can only be
|
||||||
|
one child of this type. It can have only one attribute:
|
||||||
|
|
||||||
|
.. attribute:: invisible
|
||||||
|
:noindex:
|
||||||
|
|
||||||
|
Same as for `create`, except that in this case the record itself can also be used in the
|
||||||
|
expresion.
|
||||||
|
|
||||||
.. admonition:: Possible structure and representation of its rendering
|
.. admonition:: Possible structure and representation of its rendering
|
||||||
|
|
||||||
.. list-table::
|
.. list-table::
|
||||||
@ -1702,17 +1738,12 @@ The `create` element can have the following attributes:
|
|||||||
<field name="currency"/>
|
<field name="currency"/>
|
||||||
<field name="tax_id"/>
|
<field name="tax_id"/>
|
||||||
<control>
|
<control>
|
||||||
<create string="Add a item"/>
|
<create string="Add an item"/>
|
||||||
<create string="Add a section" context="{'default_type': 'section'}"/>
|
<create string="Add a section" context="{'default_type': 'section'}"/>
|
||||||
<create string="Add a note" context="{'default_type': 'note'}"/>
|
<create string="Add a note" context="{'default_type': 'note'}"/>
|
||||||
</control>
|
</control>
|
||||||
</list>
|
</list>
|
||||||
|
|
||||||
.. note::
|
|
||||||
Using the `control` element makes sense only if the list view is inside a
|
|
||||||
:class:`~odoo.fields.One2many` or :class:`~odoo.fields.Many2many` field. If any `create` element
|
|
||||||
is defined, it overwrites the default :guilabel:`add a line` button.
|
|
||||||
|
|
||||||
.. _reference/view_architectures/search:
|
.. _reference/view_architectures/search:
|
||||||
|
|
||||||
Search
|
Search
|
||||||
@ -2925,6 +2956,11 @@ The `progressbar` element can have the following attributes:
|
|||||||
</templates>
|
</templates>
|
||||||
</kanban>
|
</kanban>
|
||||||
|
|
||||||
|
`control`: customize create and delete actions
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Like for :ref:`list views <reference/view_architectures/list/control>`.
|
||||||
|
|
||||||
.. todo::
|
.. todo::
|
||||||
- kanban-specific CSS
|
- kanban-specific CSS
|
||||||
- kanban structures/widgets (vignette, details, ...)
|
- kanban structures/widgets (vignette, details, ...)
|
||||||
|
Loading…
Reference in New Issue
Block a user