how to retive datafrom the table?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
This is the example to retreive information from database for a table.
Here [('user_id', '=', uid)] --> Here we can include the condition we put in WHERE clause
emp_obj = self.pool.get('hr.employee')
emp_ids = emp_obj.search(cr, uid, [('user_id', '=', uid)], context=context)
if emp_ids:
for employee in emp_obj.browse(cr, uid, emp_ids, context=context):
return {'name': employee.name}
--->Hope this helps you
It is recomandable to use object model to read data from the database, however some times it is more efficient to read data with SQL. If you want to read data with direct SQL, you can use the cr (cursor) that is passed to your methods as follows:
cr.execute(""" SELECT name FROM res_partner""")
result = cr.fetchall()
for partner in result:
print partner[0]
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อ