Hello All
first of all , thanks in advanced :)
I have the Following 2 fields:
freight_type = fields.Selection(
[('Ocean', 'Ocean'), ('Air', 'air'), ('Land', 'Land')],
default='',
required=True
)
ship_type = fields.Selection(
[('FCL', 'fcl'), ('LCL', 'lcl'), ('Air', 'air'), ('Land', 'land')],
default='',
required=True
)
What I tried:
@api.onchange('freight_type')
def onchange_freight_type(self):
for rec in self:
if rec.freight_type == 'Ocean':
rec.ship_type = 'FCL'
elif rec.freight_type == 'Air':
rec.ship_type = 'Air'
elif rec.freight_type == 'Land':
rec.ship_type = 'Land'
else:
rec.ship_type = ''
Not what I need, cause rec.ship_type may have 2 values
[('FCL', 'fcl'), ('LCL', 'lcl')] or one value[('Air', 'air')]
What I Need :
When I choice value 'Ocean' from field freight_type I want to filter ship_type to show only values
[('FCL', 'fcl'), ('LCL', 'lcl')]
When I choice value 'Air' from field freight_type I want to filter ship_type to show only values
[('Air', 'air')]
When I choice value 'Land' from field freight_type I want to filter ship_type to show only values
[('Land', 'land')]
So, the field ship_type will show values which depends on field freight_type
regards ,
If you don't need to show it in real time, did you think to do it in a computed field instead of the onchange