Skip to Content
Menu
This question has been flagged
2 Replies
7043 Views
hi , I am trying to call refresh() def from onchange to refresh the page but it is not working.please suggest me the alternative which can help me in this situation  

@api.multi
def refresh(self):
return {
'type': 'ir.actions.client',
'tag': 'reload',
}


@api.onchange('barcode','workorder_sequence')
def onchange_barcode(self):
if self.barcode:
workorder_id = self.env['mrp.workorder'].search([('workorder_sequence', '=', self.workorder_sequence)])
workorder_config_obj = self.env['workorder.configuration']
config_id = workorder_config_obj.search([('barcode','=',self.barcode)])
if not config_id:
self.barcode = ''
raise UserError(_(
"Invalid Barcode Detected!!!"))
else:
if config_id.name =='start':
workorder_id.button_start()
self.refresh()
if config_id.name =='done':
workorder_id.record_production()
self.refresh()
if config_id.name =='pause':
workorder_id.button_pending()
self.refresh()

Avatar
Discard
Author Best Answer

hi @jignesh , 

i tried this one . but not working 

Avatar
Discard
Best Answer

Hello rathore_mahesh,


Try this method.

def refresh(self):
    model_obj = self.env['ir.model.data']
    data_id = model_obj._get_id('module_name', 'form_view_id')
    view_id = model_obj.browse(data_id).res_id
    return {
            'type': 'ir.actions.client',
            'tag': 'reload',
            'name': _('form_name'),
            'res_model': 'model.name',
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': view_id,
            'target': 'current',

            'nodestroy': True,
        }


Hope this will helps you.

Thanks,

Avatar
Discard