Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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