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

i need to select data from the database..how this possible?

아바타
취소
베스트 답변
@api.model_cr
    def yourfunc(self):
    self._cr.execute(""" Your MYSQL COmmand Here"")
    data = self._cr.dictfetchall()
아바타
취소
작성자 베스트 답변

can u please give me the full example with fucnction defnition

아바타
취소
베스트 답변

If you're about direct queries to database, then cr.execute('select ....') is what you need, for details please refer to this page

BUT if it's not absolutelly necesary, you should prefer to use search() - browse() couple in Openerp 7.0 series and search() in Odoo 8.0.

아바타
취소
작성자

plase give me one example?

You're asking for cr.execute() example or search() example?

베스트 답변

Hi Aneesh,

You can use search function.

Search function takes a search domain, returns a recordset of matching records. Can return a subset of matching records (offset and limit parameters) and be ordered (order parameter):

EG:-

search([('is_company', '=', True), ('customer', '=', True)])

search([('is_company', '=', True)], limit=1) give one record

아바타
취소
베스트 답변

using api8,

 self.env['tablename'].search_read([], []):

아바타
취소
베스트 답변

cr. execute

I need cr. execute() example for exporting serial number, Students Names,  Father Names,  Mobile Numbers, Emails, Course, Batch,  invoice total,  amounts paid with dates,  due amount,  etc.  Any help plz? 

아바타
취소