Skip to content

Commit e69b371

Browse files
committed
[IMP] developer: explain the new <asset> tag added as a fix
Also removes outdated things in the `<template>` tag documentation and reviews it a bit. See odoo/odoo#104836 task-2963840 closes #15051 X-original-commit: 7ee3426 Related: odoo/odoo#233402 Related: odoo/enterprise#98250 Related: odoo/design-themes#1174 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
1 parent 818ba2c commit e69b371

File tree

3 files changed

+79
-7
lines changed

3 files changed

+79
-7
lines changed

content/developer/howtos/website_themes/theming.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,14 @@ By reading the source code, templates related to options are easily found.
750750
<template id="..." inherit_id="..." name="..." active="True"/>
751751
<template id="..." inherit_id="..." name="..." active="False"/>
752752
753+
.. seealso::
754+
755+
In such cases, the ``<template id="...">`` syntax should be preferred over
756+
the ``<record id="..." model="ir.ui.view">`` syntax when defining the record
757+
in XML.
758+
759+
See :ref:`reference/data/template`, especially about the ``active`` value.
760+
753761
.. _theming/module/views/presets:
754762

755763
Presets

content/developer/reference/backend/data.rst

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ data files provide shorter alternatives to defining them using
208208

209209
Defines an ``ir.ui.menu`` record with a number of defaults and fallbacks:
210210

211+
.. rst-class:: o-definition-list
212+
211213
``parent``
212214
* If a ``parent`` attribute is set, it should be the :term:`external id`
213215
of an other menu item, used as the new item's parent
@@ -239,6 +241,8 @@ Defines an ``ir.ui.menu`` record with a number of defaults and fallbacks:
239241
Creates a :ref:`QWeb view <reference/view_architectures/qweb>` requiring only the ``arch``
240242
section of the view, and allowing a few *optional* attributes:
241243

244+
.. rst-class:: o-definition-list
245+
242246
``id``
243247
the view's :term:`external identifier`
244248
``name``, ``inherit_id``, ``priority``
@@ -249,13 +253,61 @@ section of the view, and allowing a few *optional* attributes:
249253
as a primary
250254
``groups``
251255
comma-separated list of group :term:`external identifiers`
252-
``page``
253-
if set to ``"True"``, the template is a website page (linkable to,
254-
deletable)
255-
``optional``
256-
``enabled`` or ``disabled``, whether the view can be disabled (in the
257-
website interface) and its default status. If unset, the view is always
258-
enabled.
256+
``active``
257+
indicates whether the view is active. If inactive, its XPath rules won’t be
258+
applied, which is thus mainly relevant for views with ``inherit_id``
259+
260+
.. note::
261+
262+
Defining the ``active`` value on the ``<template>`` node itself comes
263+
with a subtlety: it is only considered when creating the record. On
264+
subsequent updates, the view will be updated but not its ``active``
265+
status.
266+
267+
.. _reference/data/asset:
268+
269+
``asset``
270+
---------
271+
272+
Creates an :ref:`asset <frontend/assets/ir_asset>`.
273+
274+
.. example::
275+
.. code-block:: xml
276+
277+
<asset id="website_something.some_style_asset" name="Some style asset" active="False">
278+
<bundle>web.assets_frontend</bundle>
279+
<path>website_something/static/src/some_style.scss</path>
280+
</asset>
281+
282+
**Attributes**
283+
284+
.. rst-class:: o-definition-list
285+
286+
``id``
287+
the asset's :term:`external identifier`
288+
``name``
289+
same as the corresponding field on ``ir.asset``
290+
``active`` (optional)
291+
indicates whether the asset is active
292+
293+
.. note::
294+
295+
Same as ``<template>``, defining the ``active`` value on the ``<asset>``
296+
node itself comes with a subtlety: it is only considered when creating
297+
the record. On subsequent updates, the asset will be updated but not its
298+
``active`` status.
299+
300+
**Child elements**
301+
302+
.. rst-class:: o-definition-list
303+
304+
``<bundle>`` and ``<path>``
305+
required to define the corresponding fields on ``ir.asset`` (the
306+
``directive`` field can be controlled using the ``directive`` attribute on
307+
the ``<bundle>`` child)
308+
309+
``<field>`` (optional)
310+
just like in a normal ``<record>``, to define more field values as needed
259311

260312
.. _reference/data/csvdatafiles:
261313

content/developer/reference/frontend/assets.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,15 @@ manifest counterparts.
362362
`sequence` (default= `16`)
363363
Loading order of the asset records (ascending). A sequence lower than 16 means
364364
that the asset will be processed *before* the ones declared in the manifest.
365+
366+
.. seealso::
367+
368+
Note that the ``ir.asset`` use case is mainly for website-related
369+
applications, as it allows for conditional assets (for example, when a style
370+
option is enabled).
371+
372+
In such cases, the ``<asset id="...">`` syntax should be preferred over the
373+
``<record id="..." model="ir.asset">`` syntax when defining the record in
374+
XML.
375+
376+
See :ref:`reference/data/asset`, especially about the ``active`` value.

0 commit comments

Comments
 (0)