[IMP] developer/orm: add tip on related field dependencies

This commit is contained in:
Victor Feyens 2021-05-26 10:49:33 +02:00 committed by vfe-odoo
parent 4d0f63e3eb
commit e11f010783

View File

@ -351,6 +351,17 @@ Add the attribute ``store=True`` to make it stored, just like computed
fields. Related fields are automatically recomputed when their
dependencies are modified.
.. tip::
You can specify precise field dependencies if you don't want
the related field to be recomputed on any dependency change::
nickname = fields.Char(
related='partner_id.name', store=True,
depends=['partner_id'])
# The nickname will only be recomputed when the partner_id
# is modified, not when the name is modified on the partner.
.. warning::
You cannot chain :class:`~odoo.fields.Many2many` or :class:`~odoo.fields.One2many` fields in ``related`` fields dependencies.