Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
3048 Visualizzazioni

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

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona