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 use decorator controller which is capable to handle both type='json' and type='http' for same route in odoo

By
Sah Vinay Mahabir
on 3/17/16, 7:21 AM 361 views

I want to achive something like this (This is not actual code, this is only for explanation) -

class abc(http.Controller):

    if @http.route(type='http'): @http.route('/abc', auth='public',type='http', methods=['GET','POST']) def index1(self, **kw): do_something elif @http.route(type='json'): @http.route('/abc', auth='public',type='json', methods=['GET','POST']) def index2(self, **kw): do_something_2


In summary, i need same controller ('/abc') which can handle two different type i.e. 'http' and 'json'.

if the request is of 'http' type then it handle this controller:

     @http.route('/abc', auth='public',type='http', methods=['GET','POST'])

and if the request is of 'json' type then it handle this controller:

     @http.route('/abc', auth='public',type='http', methods=['GET','POST'])

Please provide an example if you think your code may work for me, i will check your code and reply in comment.

Thank you

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: 3/17/16, 7:21 AM
Seen: 361 times
Last updated: 3/17/16, 10:57 AM