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

Error in openerp controller

By
Jose Angel Inda Herrera
on 1/28/14, 10:34 AM 978 views

I am developing a module in which I am defining a controller class (openerpweb.Controller).

I have defined a function with decorator (@ openerpweb.httprequest) because access to this function we do through a http request "httprequest". The problem is that from here I need to access to the some function model, and when I do get an error. class Json(openerpweb.Controller): _cp_path = "/df_document/json"

@openerpweb.httprequest
def load(self, req, id, do_not_eval=False):
    Model = req.session.model('document.directory')            
    directory_model = Model.search([('parent_id', '=', int(id))])

Error is raise AuthenticationError("Credentials not provided") AuthenticationError: Credentials not provided

1
Michael Watchorn
On 2/25/14, 12:04 AM

Have you tried logging in and then changing the URL in your browser?

You need to have logged in already as a user before accessing any models. You should be able to do that through code since it looks like you are goining for json, however I have no experience with that.
How come you use @openerpweb.httprequest rather than @openerpweb.jsonrequest?
I am also creating a controller, could you share where you are pulling your information/sources from? It took help from a fellow coder to point out that the documentation in trunk only works for version 8, as it was recently changed, and my install is V7.

EDIT: For V7, I found out that you need to authenticate your request. So before you attempt to access a model you need to run:

req.session.authenticate('your-db-name', 'user-name', 'password')

Then you'll be able to access the models like you wanted to.

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

0 follower(s)

Stats

Asked: 1/28/14, 10:34 AM
Seen: 978 times
Last updated: 3/16/15, 8:10 AM