javascriptpythonodooodoo-16

fields_view_get does not exist in Odoo 16


I was testing the modules of Odoo 15 that I developed in Odoo 16, I was using a lot of the method fields_views_get to have some behaviors to inject domain and context, before to render the component, but currently I can not find this method.

Someone here knows what will be the alternative to achieve some behavior in runtime (modify the XML with the etree component of lxml)?

The main goal here is to inject in the XML data that is very difficult to add without the env object since with the fields_views_get I was able to inject or make queries before returning the XML.


Solution

  • fields_view_get was renamed to get_view:

    fields_view_get becomes get_view. As it no longer returns the fields description, keeping the fields in the name fields_view_get no longer makes sense. Hence removing fields from the method name, it becomes view_get. As it gets renamed anyway, we take the opportunity to rename it get_view, which is more in line with the general getter/setter guidelines in the model object world.
    - _fields_view_get becomes _get_view. For the same reasons than above.
    - load_views becomes get_views.

    You can find more details in refactor fields_view_get, load_views commit

    In the changed files, you can see an example of commit diff of res_users model which replaces:

    def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
    

    With:

    def get_view(self, view_id=None, view_type='form', **options):