From 1898da3e8591dcabad41adae5d4db8119684c710 Mon Sep 17 00:00:00 2001 From: "Michael (mcm)" Date: Tue, 23 Nov 2021 11:34:20 +0100 Subject: [PATCH] [WIP] developer: add existing fields --- .../developer/reference/frontend/fields.rst | 399 ++++++++++++++++-- 1 file changed, 354 insertions(+), 45 deletions(-) diff --git a/content/developer/reference/frontend/fields.rst b/content/developer/reference/frontend/fields.rst index 1d25400c6..33f014f81 100644 --- a/content/developer/reference/frontend/fields.rst +++ b/content/developer/reference/frontend/fields.rst @@ -5,18 +5,85 @@ Fields In Odoo, the word *field* is mostly used to denote a part of a model, usually represented by a column in a database. Fields are represented by components in -the user interface (mostly in the form and list view). In this page, we document +the user interface (mostly in the form, kanban and list view). In this page, we document how these field components work and how to use them. How to define a field ===================== -TODO +Fields are simply owl components registered in the fields registry. + +.. code-block:: javascript + + import { registry } from "@web/core/registry"; + const { Component } = owl; + const { xml } = owl.tags; + + class CounterField extends Component { + increment() { + if (!this.props.readonly) { + this.props.update(this.props.value + 1); + } + } + } + CounterField.template = xml` +
+ +
+ `; + + registry.category("fields").add("counter", CounterField); + +The component of a field receives several props: + +.. list-table:: + :widths: 20 20 60 + :header-rows: 1 + + * - Name + - Type + - Description + * - `archs` + - `object?` + - description... + * - `attrs` + - `object` + - description... + * - `id` + - `string?` + - description... + * - `name` + - `string` + - The field's name + * - `options` + - `object` + - description... + * - `readonly` + - `boolean` + - description... + * - `required` + - `boolean` + - description... + * - `record` + - `DataPoint` + - description... + * - `type` + - `string` + - The field's base type. + * - `update` + - `function` + - description... + * - `value` + - `any` + - description... + How to use a field ================== -TODO +.. code-block:: xml + + Reference List ============== @@ -29,52 +96,294 @@ Reference List - Technical name - Type - Short Description - * - :ref:`FieldText ` - - `text` + * - :ref:`BooleanFavoriteField ` + - `boolean_favorite` + - `boolean` + - description... + * - :ref:`BooleanField ` + - `boolean` + - `boolean` + - Displays a checkbox + * - :ref:`BooleanToggleField ` + - `boolean_toggle` + - `boolean` + - description... + * - :ref:`CharField ` - `char` - - display text values - * - :ref:`OtherField ` - - `other_name` - - `text`, `many2one` - - represents some values + - `char` + - description... + * - :ref:`ColorField ` + - `color` + - `char` + - description... + * - :ref:`ColorPickerField ` + - `color_picker` + - `integer` + - description... + * - :ref:`DateField ` + - `date` + - `date`, `datetime` + - description... + * - :ref:`DateTimeField ` + - `datetime` + - `datetime` + - description... + * - :ref:`HandleField ` + - `handle` + - `integer` + - description... + * - :ref:`ImageField ` + - `image` + - `binary` + - description... + * - :ref:`Many2ManyCheckboxesField ` + - `many2many_checkboxes` + - `many2many` + - description... + * - :ref:`Many2ManyTagsField ` + - `many2many_tags` + - `many2many` + - description... + * - :ref:`Many2oneField ` + - `many2one` + - `many2one` + - description... + * - :ref:`PriorityField ` + - `priority` + - `selection` + - description... + * - :ref:`RadioField ` + - `radio` + - `many2one`, `selection` + - description... + * - :ref:`RemainingDaysField ` + - `remaining_days` + - `date`, `datetime` + - description... + * - :ref:`SelectionField ` + - `selection` + - `selection` + - description... + * - :ref:`StatInfoField ` + - `statinfo` + - `float`, `integer` + - description... + * - :ref:`StatusBarField ` + - `statusbar` + - `many2one`, `selection` + - description... + * - :ref:`TextField ` + - `text` + - `html`, `text` + - description... -.. _frontend/fields/field_text: -FieldText +.. _frontend/fields/boolean_favorite_field: + +BooleanFavoriteField +-------------------- + +- Location: `@web/fields/boolean_favorite_field` +- Technical name: `boolean_favorite` +- Supported types: `boolean` + +.. code-block:: xml + + + + +.. _frontend/fields/boolean_field: + +BooleanField +------------ + +- Location: `@web/fields/boolean_field` +- Technical name: `boolean` +- Supported types: `boolean` + +The `BooleanField` component represents a boolean value. It is the default field +for all fields of type `boolean`. + +.. code-block:: xml + + + + +.. _frontend/fields/boolean_toggle_field: + +BooleanToggleField +------------------ + +- Location: `@web/fields/boolean_toggle_field` +- Technical name: `boolean_toggle` +- Supported types: `boolean` + + +.. _frontend/fields/char_field: + +CharField +--------- + +- Location: `@web/fields/char_field` +- Technical name: `char` +- Supported types: `char` + + +.. _frontend/fields/color_field: + +ColorField +---------- + +- Location: `@web/fields/color_field` +- Technical name: `color` +- Supported types: `char` + + +.. _frontend/fields/color_picker_field: + +ColorPickerField +---------------- + +- Location: `@web/fields/color_picker_field` +- Technical name: `color_picker` +- Supported types: `integer` + + +.. _frontend/fields/date_field: + +DateField +--------- + +- Location: `@web/fields/date_field` +- Technical name: `date` +- Supported types: `date`, `datetime` + + +.. _frontend/fields/datetime_field: + +DateTimeField +------------- + +- Location: `@web/fields/datetime_field` +- Technical name: `datetime` +- Supported types: `datetime` + + +.. _frontend/fields/handle_field: + +HandleField +----------- + +- Location: `@web/fields/handle_field` +- Technical name: `handle` +- Supported types: `integer` + + +.. _frontend/fields/image_field: + +ImageField +---------- + +- Location: `@web/fields/image_field` +- Technical name: `image` +- Supported types: `binary` + + +.. _frontend/fields/many2many_checkboxes_field: + +Many2ManyCheckboxesField +------------------------ + +- Location: `@web/fields/many2many_checkboxes_field` +- Technical name: `many2many_checkboxes` +- Supported types: `many2many` + + +.. _frontend/fields/many2many_tags_field: + +Many2ManyTagsField +------------------ + +- Location: `@web/fields/many2many_tags_field` +- Technical name: `many2many_tags` +- Supported types: `many2many` + + +.. _frontend/fields/many2one_field: + +Many2OneField +------------- + +- Location: `@web/fields/many2one_field` +- Technical name: `many2one` +- Supported types: `many2one` + + +.. _frontend/fields/priority_field: + +PriorityField +------------- + +- Location: `@web/fields/priority_field` +- Technical name: `priority` +- Supported types: `selection` + + +.. _frontend/fields/radio_field: + +RadioField +---------- + +- Location: `@web/fields/radio_field` +- Technical name: `radio` +- Supported types: `many2one`, `selection` + + +.. _frontend/fields/remaining_days_field: + +RemainingDaysField +------------------ + +- Location: `@web/fields/remaining_days_field` +- Technical name: `remaining_days` +- Supported types: `date`, `datetime` + + +.. _frontend/fields/selection_field: + +SelectionField +-------------- + +- Location: `@web/fields/selection_field` +- Technical name: `selection` +- Supported types: `selection` + + +.. _frontend/fields/stat_info_field: + +StatInfoField +------------- + +- Location: `@web/fields/stat_info_field` +- Technical name: `statinfo` +- Supported types: `float`, `integer` + + +.. _frontend/fields/status_field: + +StatusBarField +-------------- + +- Location: `@web/fields/statusbar_field` +- Technical name: `statusbar` +- Supported types: `many2one`, `selection` + + +.. _frontend/fields/text_field: + +TextField --------- - Location: `@web/fields/text_field` - Technical name: `text` -- Supported types: `char` - -The `FieldText` component represents a textual value. It is the default field -for all fields of type `char`. - -.. _frontend/fields/other_field: - -Other Field ------------ - -- Location: `@web/fields/other_field` -- Technical name: `blabla` -- Supported types: `char`, `many2one` - -The `OtherField` component represents ... - -.. code-block:: xml - - - -It supports the following options: - - -.. list-table:: - :widths: 20 20 60 - :header-rows: 1 - - * - Name - - Type - - Description - * - `horizontal` - - `boolean` - - optional. if `true`, radio buttons will be displayed horizontally (default=`false`) +- Supported types: `html`, `text`