[IMP] orm: add 'any' and 'not any' operators

- Add descriptions of the 'any' and 'not any' operators
- Simplify the example for searching partners
- Add an example using the 'any' operator for the sale.order model

closes odoo/documentation#8347

Closes: #7620
X-original-commit: 7353d7b2cc
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
This commit is contained in:
Rémy Voet (ryv) 2024-03-18 11:21:26 +01:00
parent f897242171
commit bded88f121

View File

@ -939,6 +939,16 @@ A domain is a list of criteria, each criterion being a triple (either a
Takes the semantics of the model into account (i.e following the
relationship field named by
:attr:`~odoo.models.Model._parent_name`).
``any``
matches if any record in the relationship traversal through
``field_name`` (:class:`~odoo.fields.Many2one`,
:class:`~odoo.fields.One2many`, or :class:`~odoo.fields.Many2many`)
satisfies the provided domain ``value``.
``not any``
matches if no record in the relationship traversal through
``field_name`` (:class:`~odoo.fields.Many2one`,
:class:`~odoo.fields.One2many`, or :class:`~odoo.fields.Many2many`)
satisfies the provided domain ``value``.
* ``value``
variable type, must be comparable (through ``operator``) to the named
@ -960,21 +970,16 @@ Domain criteria can be combined using logical operators in *prefix* form:
.. example::
To search for partners named *ABC*, from belgium or germany, whose language
is not english::
To search for partners named *ABC*, with a phone or mobile number containing *7620*::
[('name','=','ABC'),
('language.code','!=','en_US'),
'|',('country_id.code','=','be'),
('country_id.code','=','de')]
[('name', '=', 'ABC'),
'|', ('phone','ilike','7620'), ('mobile', 'ilike', '7620')]
This domain is interpreted as:
To search sales orders to invoice that have at least one line with
a product that is out of stock::
.. code-block:: text
(name is 'ABC')
AND (language is NOT english)
AND (country is Belgium OR Germany)
[('invoice_status', '=', 'to invoice'),
('order_line', 'any', [('product_id.qty_available', '<=', 0)])]
Unlink
------