Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
8 ตอบกลับ
16846 มุมมอง

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? 

อวตาร
ละทิ้ง