Odoo Help


1 Answer

Timo Talvitie, Vizucom Oy Finland

--Timo Talvitie, Vizucom Oy--
| 5 4 9
Tampere, Finland
--Timo Talvitie, Vizucom Oy--

Lead developer at Vizucom.

Timo Talvitie, Vizucom Oy Finland
8/1/17, 11:28 AM

First you need to define the button inside a <form> tag in the website template XML, e.g.

<form action="/my_new_controller" method="post">
<!-- put other forms field here if you need to pass info to controller -->
<button type="submit" class="btn">Call a controller</button>

Clicking the  button submits the form and calls the controller at www.myodoosite.com/my_new_controller. You can define the controller in python with something like this:

class website_account(http.Controller):

  @http.route(['/my_new_controller'], type='http', auth='public', website=True)
def my_controller_method(self, redirect=None, **post):
# Put your backend operations here, e.g.
# sale_model = request.env['sale.order']
# sale_model.create({...})

# After you're done, use either request.render() or request.redirect() to show
# a different page to the user. You can check out the website_portal module for examples.

Ask a Question
Keep Informed
1 follower(s)
About This Community

This platform 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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now