Hello odooers & developers,
Its odoo tips and tricks article, where I would like to share more knowledge about the o2m dynamic domain in Odoo 17
as an odoo developer, knowing the fundamentals of o2m Dynamic Domain Filtering in Odoo behaviour, its Syntax, and how we can use the o2m dynamic domain in Odoo is essential.
Explore o2m Dynamic Domain Method :-
This code sets up a dynamic domain for the O2M field.
"domain=lambda self: self._compute_child_domain()": This is the key part. It sets the domain for the O2M field. Here, it uses a lambda function to dynamically call the _compute_child_domain method whenever the domain needs to be evaluated. This ensures the domain is updated based on the current record's "status" and model.
o2m Dynamic Domain Method Usage and Syntax:-
.py
@api.depends('status')
def _compute_child_domain(self):
for record in self:
return [('model', '=', record._name)]
review_ids = fields.One2many(
comodel_name='approval.request', inverse_name='res_id',
string='Validations',
auto_join=True,
domain=lambda self: self._compute_child_domain()
)
If you want specific odoo tips or tricks, please let us know the topic of your tips by mail at [email protected]. Then next, we would like to write a tips article based on your suggested topics, too
Devintellecs & team are odoo services providers in the USA and INDIA, so we will try our best to write the best content on your tips request
if you want to check your odoo technical or functional knowledge, then we have prepared the odoo EXam practice test for the odoo technical & functional people
Thanks, & Stay tuned for the following odoo tips soon...
How to Apply o2m dynamic domain