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

Hi

I want to get some information from treeview once clicked a button on the related line.

Is this possible? If it is possible how can I do this?


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

Hi,

if you click the button in a record inside the tree view, you can access the field values of the same using the self.

Example: Suppose if the sale order tree view is editable and there is a button in the lines, once the button of any line is clicked you can access the values of that line using self, make sure the button is of type object which call a python function, inside the function you can access rest of the field values using  self.field_name


You can iterate self over the for loop to prevent singleton error.

Thanks

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

You can add a button the tree view of the model records, and get the the id of the active record with the help of self._context.get('active_id', False).

If self._context doesn't have a key called active_id you can pass it from the button like

<button name="python_function_that_button_calls" type="object" context="{'active_id': active_id}" string="Click Here"/>

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

Thanks, I managed to get values I wanted. It actually works exactly @Niyas Raphy said.

Ả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
5081
5
thg 11 23
43454
3
thg 9 23
9677
1
thg 9 22
3969
1
thg 6 22
12775