콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
11747 화면

Hi All ,


Am trying to retrieve project data from model project.project and display on a customized website module in odoo 8. 

So far i have the module created and installed.  See code below for what i have. 


models.py 

from openerp import models, fields, api

#Just inherit default odoo project.project fields

class project_category(models.Model):

_name='project.project'

_inherit='project.project'

controllers.py

class Website(http.Controller):
@http.route('/index',auth='public',website=True)
def list(self,**kw):
projects = http.request.env['project.project']
print "Test is below "
print projects # this prints project.project() which i think its an empty array. My goal is to retrieve projects and render them on

# template layout
return http.request.render('website.layout',
{'categories':projects.search([])
})

Any suggestions most welcomed. Thank you.

아바타
취소
작성자 베스트 답변

Solved this issue. I realized the array is empty because i was printing before calling search() method which performs read operations. 

On the template side templates.xml i accessed projects by

<t t-foreach="categories" t-as="category">

 <t  t-esc="category.name" />

</t>

Thanks


아바타
취소
관련 게시물 답글 화면 활동
2
6월 16
3697
2
7월 25
199
4
6월 25
529
1
6월 25
825
1
5월 25
889