コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4790 ビュー

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 ?


アバター
破棄
著作者

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 ?

最善の回答

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)."

アバター
破棄
関連投稿 返信 ビュー 活動
0
10月 23
1608
4
10月 18
8382
3
6月 18
6947
2
12月 21
26231
1
12月 19
3532