Skip to Content
Menu
This question has been flagged
1 Reply
13226 Views

Hi guys,

I would like to redirect view right after action is done.
As an example: 

In form, once i fill all required fields and tables clicking on button which change state (draft -> warehouse) in this moment i would like to change view back to 'kanban'

I tried using attrs but even if state is changed to 'warehouse' I can still see the form.

I hope my explanation are clear enough to understand what I would like to achieve ?




Avatar
Discard
Best Answer

Rob,

ROB,

"Please change the decorator from @api.one to @api.multi, as @api.one doesn't allow return action item."

def your_function(...........):
[your operation]
  return {
'name': _('Your String'),
'view_type': 'form',
'view_mode': 'kanban,tree,form',
'res_model': 'iprodstep.log',
'view_id': False,
  'type': 'ir.actions.act_window',
'target': 'current',
'nodestroy': True
}

Hop this will help you.....!    

Avatar
Discard
Author

Helpful as always :) Thank you Pawan

Author

Did you read my message ?

Author

So at the end, right after:

	@api.one
	def state_in(self):
		self.write({'state': 'in',
					'date_in': time.strftime(server_datetime)}
...here...
)
i should add
return {

'nodestroy': False,

 'view_type': 'form',

'view_mode': 'kanban',

'res_model': [your_model],

'view_id': [your_kanban_view_id],

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

}

??
Author
	@api.one
	def state_out(self):
		self.write({'state': 'out',
					'date_out': time.strftime(server_datetime),
					'nodestroy': False,
					'view_type': 'kanban',
					'res_model': 'iprodstep.log',
					'view_id': 'iprodstep_log_kanban',
					'type': 'ir.actions.act.window'
					})
it doesn't work like that :(

Rob, check the update answer and replace the return with this thing....

Author

Unfortunately ...... :(

 return{

'name': _('Your String'), #what you mean ? view name ? iprodstep_log.kanban ?

'view_type': 'form',
Author
			return{
					'name': _iprodstep_log.kanban,
					'view_type': 'form',
					'view_mode': 'kanban,tree,form',
					'res_model': 'iprodstep.log',
					'view_id': False,
					'type': 'ir.actions.act_window',
					'target': 'current',
					'nodestroy': True
					}
:( nothing

_(Your string) means any string you want to display in header....
you can remove "view_id" part

Author

OK, i'll try, one more question if you can answer. How can i copy value from one field to another?

	@api.onchange('product_id')
	def check_change(self):
		self.image_url:value = self.item_id:value

you can return,
return {'value': {'image_url': [you_value]}}

Author

Whatever I add as a name it won't work. or gives me an error :

return {'name': _iprodstep_log.kanban, NameError: global name '_iprodstep_log' is not defined

ho exatly should it look like ?
'name': _('name?')
or
'name:' _'name'
or
'name': _name
or
'name': name?
i tried almost everything and either it just doesn't work or gives me an error "not defined"
Author

You said "any name" so i tried 'My_view', '_S....t_view' :):):) doesn't help ;(

Rob, its just a string you need to pass there....... nothing else.....
{'name': 'ROB',.............}, thats it..........

Author

I understand it Pawan, problem is whatever I type there it either doesn't work or gives me an error ... I'll try again :)

Author
return {'name': 'Robert',
	    'view_type': 'kanban',
	    'view_mode': 'kanban,form',
	    'res_model': 'iprodstep.log',
	    'type': 'ir.actions.act_window',
	    'target': 'current',
	    'nodestroy': True
    	   }
So it should be like that ..... doesn't work ..... Change state but view is still the same.

Rob, "view_type" has to be "form" only.....

Author
	@api.one
	def state_out(self):
		self.write({'state': 'out',
					'date_out': time.strftime(server_datetime),})
		return {'name': 'Robert',
				'view_type': 'form',
				'view_mode': 'kanban,form',
				'res_model': 'iprodstep.log',
				'type': 'ir.actions.act_window',
				'target': 'current',
				'nodestroy': True
				}# changing state to out - from warehouse to technicians

doesn't work anyway :(