Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
6770 Lượt xem

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!

Ảnh đại diện
Huỷ bỏ

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

Tác giả Câu trả lời hay nhất

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?

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 4 25
4930
5
thg 11 23
43276
3
thg 9 23
9613
1
thg 9 22
3901
1
thg 6 22
12695