Skip to content

Commit

Permalink
[IMP] developer/reference: deprecated path traversal in mapped Model.…
Browse files Browse the repository at this point in the history
…mapped()

odoo/odoo#187299
  • Loading branch information
kmagusiak committed Nov 18, 2024
1 parent 07122aa commit 05e33cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 8 additions & 4 deletions content/developer/reference/backend/orm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1086,13 +1086,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
~~~~
Expand Down
2 changes: 2 additions & 0 deletions content/developer/reference/backend/orm/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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
=================
Expand Down
2 changes: 1 addition & 1 deletion content/developer/tutorials/pdf_reports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down

0 comments on commit 05e33cd

Please sign in to comment.