odoo-9

Odoo: URL not found if not auth


I have controller with route:

@http.route(['/report/yandex_phone_report'], type='http', auth="public", website=True)
def yandex_phone_report(self, **kw):
    page_data = []


    return  http.request.render(self._report_index_page_template, {
        'page_items': page_data

If I logged in URL /report/yandex_phone_report displayed fine. If I not loged in URL /report/yandex_phone_report is returning 404:

2017-08-02 16:46:09,400 5942 INFO ? werkzeug: 127.0.0.1 - - [02/Aug/2017 16:46:09] "GET /report/yandex_phone_report HTTP/1.1" 404 -

Browser is displaying this:

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

How can I fix it? Why route is not working?


Solution

  • It happens because it doesn't know on which database to look for that URL.

    If you look on the log you provided, you will see that after INFO, you have ?

    2017-08-02 16:46:09,400 5942 INFO ? <- THIS ONE
    

    Instead of ?, you see a database name, if it knows which database it should use.

    To test it, you can first call: http://localhost:PORT/web?db=YOUR_DB_NAME

    This will setup the session on the browser for the given database.

    Then, calling http://localhost:PORT/report/yandex_phone_report will work.

    On a production environment, you will need to configure it to get the database name from somewhere... From the URL, for instance (http://dbname.example.com:PORT).