跳至内容
菜单
此问题已终结
1 回复
1768 查看

i inherit module which have selection field and itry to change value of it 

Itry to kep key and change value only but it has 5 values but i want only 4

so last one its still appear


形象
丢弃
最佳答案

You need to redefine the selection field in your inherited model and remove the key-value you want to remove.

Updated Answer:

try to call a method to get the options as below:


diet = fields.Selection(selection="_get_selection_diet_options",required=False)

def _get_selection_diet_options(self):
return [('dry', _("Dry")),('wet', _("Wet"))]


形象
丢弃
编写者

I remove value from inherent model but it still appear
:this is in original model:
diet = fields.Selection([('vegetarian', 'Vegetarian'),('lacto', 'Lact'),
('milk', 'milk')], 'Diet Type',required=True)
the inherit:
diet= fields.Selection([('dry', 'Dry '),('wet', 'Wet'),
]
,required=False)

I have updated my answer

This works! Thank you