Question Details

No question body available.

Tags

odoo odoo-17

Answers (1)

September 17, 2025 Score: 1 Rep: 300 Quality: Low Completeness: 50%

If you look at Odoo's source code you'll see this

class StockQuant(models.Model):
    onhand = fields.Boolean('On Hand', store=False, search='searchonhand')

Which means that the onhand field is not stored in the database, but calculated

My guess is that only search does the proper filtering in the database, but the other methods don't, so better stick with it.

You can also do this (from my own Odoo instance)

In [2]: p=env['product.product'].browse(6275)

In [3]: p Out[3]: product.product(6275,)

In [4]: p.stock
quantids Out[4]: stock.quant(11431, 14798, 16564, 126403, 133012, 166809)

In [5]: p.stock
quantids.mapped('id') Out[5]: [11431, 14798, 16564, 126403, 133012, 166809]

In [6]: env['stock.quant'].search([('id', 'in', p.stock
quantids.mapped('id')), ('onhand', '=', True)]) Out[6]: stock.quant(126403, 133012, 166809)