pythonodooodoo-14

empty recordset. Why?


In a Odoo 14 shell, I'm doing this

env['model_A'].search(['model_B_id', '=', '17' ])

I know for sure that there are several records in model_A with the field model_B_id set to 17

I get an empty recordset back

model_A()

Why ?


Solution

  • The correct form of the search is

    env['model_A'].search([('model_B_id', '=', 17)])
    

    Elements to search must be a list of tuples and the many2one relation need an integer