This question has been flagged

Hello,

I want to return a view from a onchange function ,but not able to redirect ..

Here is my code

@api.multi

@api.onchange('product_id')

def product_id_change(self):
        model_obj = self.env['ir.model.data']    

    [ if not self.product_id:
        return {'domain': {'product_uom': []}}        vals = {}  
        domain = {'product_uom': [('category_id', '=', self.product_id.uom_id.category_id.id)]}............]

         data_id = model_obj._get_id('hotelbeds', 'view_search_hotel')   

         view_ids = model_obj.browse(data_id).res_id

        return {       

                        'type': 'ir.actions.act_window',       

                        'name': _('Hotel Search'),   

                        'domain': domain,     

                        'view_id' :view_ids,     

                       'view_type': 'form',   

                       'view_mode': 'form',      

                      'res_model': 'hotel.search',  

                      'target': 'new'     

                      }

Avatar
Discard

I faced the same issue

Best Answer

HI Naresh, I Haven't tested yet to return act window,
But as far as I know onchange can only return value, warning or domain.

Regards

Avatar
Discard
Author

Yes,onchange function is not expected to return anything instead it is only used to alter in-memory changes.