I have this field in my model:
class Embed_Ingredients (models.Model):
_name = 'afribon_productapp.embed_ingredients'
_description = 'a description'
GLOBAL_IMPORT_OPTIONS = [('less', '<1 ton'), ('greater', '> 1 ton')]
procurement = fields.Selection ( [('imported', 'Imported'), ('local', 'Local')], default = 'imported', required = True )
freight_greater_or_less = fields.Selection (
GLOBAL_IMPORT_OPTIONS,
string = "Weight",
default = 'less'
)
@ api.onchange (' procurement ')
def procurement_change (self):
' ''
When user changes procument to `local`, add a new value to the global variable GLOBAL_IMPORT_OPTIONS
'' '
if self.procurement ==' local ':
self.GLOBAL_IMPORT_OPTIONS.append ((' full_load_container ',' Full Load Container '))
print (self.GLOBAL_IMPORT_OPTIONS)
When the 'procurement' selection changes to local, I would like to add a new value into the GLOBAL_IMPORT_OPTIONS variable
When I print the value of GLOBAL_IMPORT_OPTIONS in the terminal, I can see that the value has been appended into the list, but on the form view, I cannot see the new value in the selection dropdown.
Thanks!