跳至內容
選單
此問題已被標幟
3 回覆
5848 瀏覽次數

 



i need to take the values Current Year, Previous year etc. dynamically from a table(model)

頭像
捨棄
最佳答案

try many2one field for selection widget.

頭像
捨棄
作者

in dashboard?

最佳答案

Two Ways for this:

1. First you can call a function in selection field to get the options for the field. Here is an example:

@api.model

    def get_field_options(self):

        #compute the list as per your requirement and for the list in format below

        value_list = [('one','option 1'),('two','option 2')]

        return value_list

dynamic_field = fields.Selection(selection='get_field_options', string="Field Dummy")


2. If you just need values from a table as a selection, then try many2one field with selection widget.


Hope this helps :)

頭像
捨棄
作者

thanks for the answer shyam. But the actual problem is not this. I want this field to be shown in dashboard as editable selection field.

相關帖文 回覆 瀏覽次數 活動
1
8月 24
1427
2
6月 24
1867
1
3月 23
3493
1
10月 20
3613
1
2月 20
6806