pycharm-odoo
pycharm-odoo copied to clipboard
Model and field reference in _depends definition
_depends = {}
"""dependencies of models backed up by SQL views
``{model_name: field_names}``, where ``field_names`` is an iterable.
This is only used to determine the changes to flush to database before
executing ``search()`` or ``read_group()``. It won't be used for cache
invalidation or recomputing fields.
"""
https://github.com/odoo/odoo/blob/4d184bc6ca3b1308ffd7c890928b1c3244f89d45/odoo/models.py#L522
Example of usage:
_depends = {
'account.invoice.report': ['invoice_date', 'partner_id', 'price_subtotal', 'state', 'move_type'],
'crm.lead': ['partner_assigned_id'],
'res.partner': ['activation', 'country_id', 'date_partnership', 'date_review',
'grade_id', 'parent_id', 'team_id', 'user_id'],
}
https://github.com/odoo/odoo/blob/4d184bc6ca3b1308ffd7c890928b1c3244f89d45/addons/website_crm_partner_assign/report/crm_partner_report.py#L25
I didn't knew this attribute existed. Now I have something new to study.
Also, in odoo-stubs: _depends: Any in several versions. Shouldn't be changed to _depends: Dict[str, List[str]] ?
Also, in
odoo-stubs:_depends: Anyin several versions. Shouldn't be changed to_depends: Dict[str, List[str]]?
Yup!