Skip to Content
Menú
This question has been flagged
1 Respondre
2110 Vistes

I have created a custom form in Odoo17, with this controller getting the data from the input through an http route: 


from odoo.http import request, Controller, route

@route('/form', auth='public', website=True)
def form(self, **kwargs):
error_message = request.session.pop('error_message', None)
return request.render('module.form_template', {'error_message': error_message,})


@route('/form/submit', type='http', auth='public', website=True, methods=['POST', 'GET'])
def form_submit(self, **post):
...


and from the xml, I have a form: 

 

form action="/form/submit" method="POST" enctype="multipart/form-data" class="o_mark_required" data-mark="*"
data-model_name="" data-success-page=""
input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"


and some inputs: 


input class="form-control s_website_form_input"
name="input_id" required="1"
placeholder="Please fill the input"
t-att-value="input_id"
t-att-disabled="condition"


Locally everything is working fine, the form gets submitted etc.

But when deployed and built in Odoo sh, I receive this:

Request URL:https://....odoo.com/form/submit
Request Method:POST
Status Code:303 See Other
Remote Address:xx.xxx.xx.xxx:xxx
Referrer Policy:strict-origin-when-cross-origin

Does any of you know or have a hint on what is wrong with the above or what exactly what might happen for this to appear? 


Thank you! 




Avatar
Descartar
Best Answer

Hi,

The 303 See Other status code you’re seeing after form submission is standard behavior in Odoo’s web controllers. It indicates a redirect, not an error — your form is likely working correctly unless data isn’t being saved or redirected properly.


Here are a few key points to understand and verify:


    303 is expected after POST:

    Odoo uses 303 See Other to redirect users after a form is submitted, to avoid resubmitting data if the page is reloaded.


    You should explicitly redirect:

    At the end of your /form/submit method, make sure you return something like:

    return request.redirect('/thank-you') — otherwise the browser won’t know where to go next.


    CSRF token must be valid:

    Ensure your form includes a valid CSRF token using

    t-att-value="request.csrf_token()". An invalid or missing token can block submission.


    Check network tab for behavior:

    In your browser dev tools, look for a 303 POST request followed by a GET request to the redirected URL. That’s a sign it’s working properly.


    Redirect target must exist:

    If you redirect to /thank-you, make sure that URL is defined in your routes or templates. Otherwise, you’ll see a blank or error page.


    Handle success messages via session:

    You can show messages on the next page using request.session['success_message'] and displaying it in your template.


Hope it helps.

Avatar
Descartar
Related Posts Respostes Vistes Activitat
1
de març 18
13251
1
de juny 15
7601
1
de març 15
13792
4
d’oct. 20
5612
2
de març 16
4335