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

Hi,


if I call model.browse('234') although there isn't any record with id '234', the result responds to ensure_one() and len. The only way to raise an exception is to call name attribute.

What is the best way to ensure browse returns an existing record?


Thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

if record.exists():
# record existed
https://github.com/odoo/odoo/blob/12.0/odoo/models.py#L4316

อวตาร
ละทิ้ง