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

Hi,


I would like to know what the default_get function returns exactly.  Is it possible to return a list of dict for example ?

The goal is to show several entries for each field in a tree view (in a wizard).

And if not possible, which methods I can use instead ?


Ảnh đại diện
Huỷ bỏ
Tác giả

Hello Mohammed,

default_get returns "a dictionary mapping each field name to its corresponding default value; the keys of the dictionary are the fields in fields_list that have a default value different from False."

So if I understood well, the structure must be {key1:value, key2:value}.

But is it possible to have nested structures ? like {dict1: {key1:value, key2:value}, dict2: {key1:value, key2:value}}. It seems Odoo doesn't accept this last kind of structure in the default_get, or I'm wrong ?

Câu trả lời hay nhất

Hello,

As per my understanding default_get fun is called when creating a record to write default values.

@api.model
def default_get(self, fields):
res = super(RegistrationEditor, self).default_get(fields)

Here res will be a dictionary with default values to be given to fields and fields a list of all fields.

what exactly do you mean by "show several entries for each field in a tree view (in a wizard)."

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 23
1603
4
thg 10 18
8367
3
thg 6 18
6927
2
thg 12 21
26212
1
thg 12 19
3511