跳至内容
菜单
此问题已终结
1 回复
21224 查看

i want to add new button on the web page and perfome action on the button in odoo 9

anybody plz help me

形象
丢弃
最佳答案

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>
</form>

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.


形象
丢弃
相关帖文 回复 查看 活动
1
12月 24
6044
3
8月 24
6895
4
7月 24
41203
1
2月 24
2063
5
4月 23
98953