Use IDs or Model objects as operands on domains?

In domain queries I’ve been using model objects as operands instead of it’s id. (‘party’, ‘=’, a_party) vs (‘party’, ‘=’ a_party.id).

I was stuck for a while with a many2many where my domain query throw an error. I changed it to passed the id of the model as the operand and now it works.

May be I am doing something wrong on the m2m domain query.

Should I use instances of models, ids or both as operands?
Is there a reason to use models instead of ids, a part from the fact that I do not need to check if the model exists to get it’s id?

Indeed the unittest only ensure that it works with ID but it is a side effect of the implementation that it works with model instance.

Indeed it is a nice feature to avoid the need for testing against None.
So to have this as a real feature, we need to have test for all kind of fields and to fix the issue with Many2Many.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.