[IMP] developer/reference: deprecated path traversal in mapped Model.mapped()

odoo/odoo#187299
This commit is contained in:
Krzysztof Magusiak (krma) 2024-09-02 14:45:49 +00:00
parent 183fa4245d
commit 8df16d7afe
3 changed files with 11 additions and 5 deletions

View File

@ -1113,13 +1113,17 @@ Map
.. note::
Since V13, multi-relational field access is supported and works like a mapped call:
Accessing relational attributes returns the union of the recordsets.
You should probably always use simple attribute access and only ``mapped``
when you may have multiple records and you want to get a value for each
record in the recordset.
.. code-block:: python3
records.partner_id # == records.mapped('partner_id')
records.partner_id.bank_ids # == records.mapped('partner_id.bank_ids')
records.partner_id.mapped('name') # == records.mapped('partner_id.name')
records.partner_id # union of partner_id from records
records.mapped('partner_id') # same as previous
records.partner_id.bank_ids # union of banks of partners of records
records.partner_id.mapped('name') # for each partner of records, get the name
Sort
~~~~

View File

@ -12,6 +12,8 @@ Odoo Online version 18.1
- Declare constraints and indexes as model attributes with `#175783 <https://github.com/odoo/odoo/pull/175783>`_.
- The `json` controllers have been renamed to `jsonrpc`. They are called the same, only the
`type` in the python files changed. See `#183636 <https://github.com/odoo/odoo/pull/183636>`_.
- Models' `mapped` and `filtered` stop accepting paths as strings.
See `#187299 <https://github.com/odoo/odoo/pull/187299>`_.
Odoo version 18.0
=================

View File

@ -124,7 +124,7 @@ our minimal property offers template file:
</tr>
</thead>
<tbody>
<t t-set="offers" t-value="property.mapped('offer_ids')"/>
<t t-set="offers" t-value="property.offer_ids"/>
<tr t-foreach="offers" t-as="offer">
<td>
<span t-field="offer.price"/>