Skip to Content
Menu
This question has been flagged
2 Replies
5739 Views

I need change tree view column name with something calculated from the record value. Anybody knows how I can do that?


When I follow the link http://elico-corp.com.sg/2015/10/01/how-to-tech-dynamically-modify-your-view/, I found in the old version odoo can pass context parameter in the fields_view_get function. However in Odoo 13, the context parameter is the function  is removed.  Does anyone know why?

@api.model

def fields_view_get(self, view_id=None, view_type=’tree’, context=None, toolbar=False,submenu=False):


However in Odoo 13, the context parameter is the function  is removed.  Does anyone know why?


Any help would be appreciated!

Avatar
Discard

context is now available as self._context or self.env.context. It is not removed, but it is moved to environment. You can pass context as self.with_context(my_special=True). Have a look at - https://www.odoo.com/documentation/13.0/reference/orm.html#altering-the-environment

Author Best Answer

Thanks for your reply. I am trying to pass context value into the method for example: 

@api.model

def fields_view_get(self, view_id=None, view_type=’tree’, toolbar=False,submenu=False):

...

context_p_value= self.env.context.get('some_variable', False)

...


And I have the a tree view 

    <field 

                          name="worksheet_reslut_line_ids" 

                                 widget="one2many"

                                 context="{

                                    'some_variable': some_variable

                                    'tree_view_ref' : 'my_module.my_tree_view'}"

                                 width="100%"

                                >

    ... 

</field>


I know @api.model is a class level decorator. Do you think it is right way to do so? Any other ways to do so?

Avatar
Discard
Related Posts Replies Views Activity
0
Oct 24
3
5
Nov 23
40248
3
Sep 23
7672
2
Jan 24
2327
1
Sep 22
2142