I've encountered an issue while trying to fetch data from the database using jsonRpc through the Odoo API. The error message I received was "HTTP/1.1 GET /projects - 404 Not Found".
Below is the snippet of my code:
A Python script used for data manipulation:
class project:
def GET(self):
print("get")
data=[]
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Credentials', 'true')
web.header('Content-Type', 'application/json')
auth = web.input()
print(auth)
odoo = odoorpc.ODOO('field.holisticbs.com',port=8069)
odoo.login('field.holisticbs.com','[email protected]','admin')
Project = odoo.execute('project.task','search_read',[[['company_id', '=', int(auth.company)],['user_id','=',int(auth.user)]]])
return json.dumps(Project)
controller.js:
controller('projectCtrl',function ($scope,API,$localStorage,localStorageService) {
console.log("Project ctrl");
API.showLoad();
var resource = "projects";
API.getData(resource, localStorageService.get('user')).then(function(data) {
console.log(data);
$scope.projects = data;
}).catch(function(data, status) {
alert("error in request");
}).finally(function() {
console.log("finally finished projects");
API.hideLoad();
});
})
service.js:
function getDetails(resource,data) {
console.log(resource);
console.log(data);
var request = $http({
method: "get",
url: backend+resource,
params: {instance: data.inst, user:data.user, company:data.company}
});
return(request.then( handleSuccess, handleError ));
}
project.html (view page displaying blank):
<ion-view view-title="Projects">
<ion-content>
<ion-list>
<div class="card" ng-contoller="projectCtrl">
<a class="button button-icon" href="#/app/newProject">
<button class="button button-positive">Create Project</button> </a>
<h2> project </h2>
<ion-item ng-repeat="proj in projects" href="#/app/projects/{{proj.id}}">
<h2 class="padding">{{proj.id}}. {{proj.name}}</h2>
<div class="row" ng-if="proj.partner_id[1]">
<span class="col col-25">Customer:</span>
<span class="col">{{proj.partner_id[1]}}</span>
</div>
<div class="row" ng-if="quot.date_order">
<span class="col col-25">Date:</span>
<span class="col">{{proj.date_order}}</span>
</div>
<div class="row" ng-if="quot.state">
<span class="col col-25">Status:</span>
<span class="col">{{proj.state}}</span>
</div>
</ion-item>
</div>
</ion-list>
</ion-content>
</ion-view>