Can I use env variable in a properties domain definition?
I have a model/table containing the user ID as a property to restrict information to a specific user. A simple definition of the table looks like the following:
We assume the name of this model is "baz".
I have a one2many property "baz" in another model refering to the "baz" model on its product_id:
baz = fields.One2many('baz', 'product_id')
If I would now search for each product that is within a specific search (like IN (100,101) ) I would get the rows 1-4. But how should I do if I only want to get the rows that belongs to the current user, defined in the user_id column? How can I achieve that this information is used for extra filtering?
I've tried to make use of the domain attribute in a properties definition to make a more detailed search based on the user_id field:
baz = fields.One2many('baz', 'product_id', domain="[('user_id', '=', " + self.env.user.id + ")]")
But there is no access to the self information at the properties definition.
How can I do it or there other ways to restrict information to a user?
For more detail: the data are directly written in the read() method of the model just before the data are accessed to get the freshest information. To avoid that another process writes the same information we hold the data per user and only want to show his particular information that were previously inserted.
(I'm using odoo v8)