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

I was reading odoo15 documentation and found the group_expand field attribute but I didn't understand its work. 

would anyone help me understand where and how to use it? 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi, 

In a Kanban view, the use of Kanban states is highly beneficial, allowing records in each state to be draggable. To display these states in the Kanban view, the 'group_expand' attribute comes into play. By incorporating this attribute in the field declaration, the Kanban view will showcase the states even when no records are present in a particular state.


Example:

service_state = fields.Selection([('draft', 'Draft'), ('assigned', 'Assigned'),

                                 ('completed', 'Completed'), ('returned', 'Returned'),

                                 ('not_solved', 'Not solved')],

                                string='Service Status', group_expand='_group_expand_states',

                                default='draft', track_visibility='always')

In this example, the 'group_expand' attribute contains a function named ‘_group_expand_states.’ The function is defined as follows:

def _group_expand_states(self, states, domain, order):

   return [key for key, val in type(self).service_state.selection]


Here, the function '_group_expand_states' returns a list of states. It aims to pass all the selection fields in list form to the 'group_expand' method. In the XML, the state field is defined as a regular field, as illustrated in the above example.

Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 9 25
2097
1
thg 7 21
2949
0
thg 4 16
4586
1
thg 5 15
4149
2
thg 3 15
5062