Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to redirect view after action is done?

By
Dr Obx
on 9/7/15, 10:41 AM 1,023 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 ?




4

Pawan

--Pawan--
1267
| 4 3 5
Hyderabad, India
--Pawan--


Pawan
On 9/7/15, 10:59 AM

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.....!    

Helpful as always :) Thank you Pawan

Dr Obx
on 9/7/15, 11:26 AM

Did you read my message ?

Dr Obx
on 9/7/15, 11:27 AM

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',

}

??
Dr Obx
on 9/7/15, 11:49 AM
	@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 :(
Dr Obx
on 9/7/15, 12:00 PM

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

Pawan
on 9/8/15, 2:14 AM

Unfortunately ...... :(

 return{

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

'view_type': 'form',
Dr Obx
on 9/8/15, 8:43 AM
			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
Dr Obx
on 9/8/15, 8:45 AM

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

Pawan
on 9/8/15, 9:04 AM

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
Dr Obx
on 9/8/15, 9:08 AM

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

Pawan
on 9/8/15, 9:47 AM

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"
Dr Obx
on 9/9/15, 3:01 AM

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

Dr Obx
on 9/9/15, 3:02 AM

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

Pawan
on 9/9/15, 4:21 AM

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

Dr Obx
on 9/9/15, 4:42 AM
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.
Dr Obx
on 9/9/15, 4:47 AM

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

Pawan
on 9/9/15, 6:10 AM
	@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 :(
Dr Obx
on 9/9/15, 9:39 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/7/15, 10:41 AM
Seen: 1023 times
Last updated: 9/10/15, 1:48 AM