Reputation: 1079
I am using odoo 10e what i want to do is that when a user click a button i want to redirect him to a html page and show him ThankYou msg. Like we see when we submit a survey on google. It show us thankyou page in last and we are even not able to go back and submit the survery again.
According to my knowledge if i want to redirect user to a url we can use following.
return {
'type': 'ir.actions.act_url',
'url': 'www.google.com',
'target': 'self'
}
But i want to show my own page like suppose if i have index.html file in my custome module.
Upvotes: 0
Views: 2356
Reputation: 989
To redirect to another page, you have two ways:
if you do it from a model you have to add a button object typein the view to execute the method of your model and then in the model you redirect it with:
<button name="my_page" string="My text" type="object"/>
Now in the model:
class MyModel(models.Model):
_inherit = "my_module.my_model"
@api.multi
def my_page(self):
return {
"url": "/my_module/my_page/",
"type": "ir.actions.act_url"
}
the other is from the controller:
from werkzeug.utils import redirect
from openerp import http
class main(http.Controller):
@http.route('/my_module/my_page/', auth='public')
def index(self, **kw):
response = redirect("www.google.com")
return response
in this example the button calls the method 'my_page' of the model and this calls the url of the controller '/my_module/my_page/', but you can redirect directly from the model to the url you need, also in the controller. For example, if you need to go directly from the model to an url without going through the controller, you can use:
return {
'url': 'http://google.com',
'type': 'ir.actions.act_url'
}
Upvotes: 1