I need to call function in domain odoo 16
I know that calling function in domain depricated in odoo16
but how can i solve this problem?
I tried to use compute field but it does't work
@api.onchange('deliver_id.shipping_method')
def _on_change_shipping_method(self):
if self.deliver_id.Shipping_method:
cities=self.env['shipping.meth']['line_ids']['city_id'].search_read()
city_list={}
for rec in cities:
cit=self.deliver_id.Shipping_method.line_ids.city_id
for c in cit:
if rec['id'] == c.id:
city_list[c.id]=c.id
return city_list
@api.depends("deliver_id.Shipping_method")
def _compute_allowed_value_ids(self):
for record in self:
x= _on_change_shipping_method()
x=list(x.values())
record.allowed_value_ids=x
allowed_value_ids = fields.Many2one(
"city.city",
_compute="_compute_allowed_value_ids",required=False
)
city = fields.Many2one('city.city',string='City',domain="[('id', 'in', allowed_value_ids)]",)