Using Odoo 10 (fetched from GitHub commit 7413b26, branch 10.0
), I try to use the environnement in a search filter domain applied to a tree view. Like this:
<filter string="Metal" domain="[('attribute_id','=', self.env['ir.config_parameter'].get_param('my_module.attrib_metal', None))]" help="metal"/>
But Odoo won't let me use self
:
NameError: name 'self' is not defined
I also tried to filter my attrib_metal
with Python by saving the result in a field but I don't want to store it in my database, however Odoo search requires it to be.
In my Python:
def get_my_params(self):
attrid = self.env['ir.config_parameter'].get_param(
'my_module.attrib_metal', None)
if attrid:
for rec in self:
setattr(rec, attrib_metal, rec.attribute_id.id == int(attrid))
attrib_metal = fields.Boolean(store=False, compute="get_cr_params")
This code is part of an inhereted product.attribute.value
model.
In my XML view:
<filter string="Metal" domain="[('attrib_metal', '=', 'True')]" help="metal"/>
I have tried with the store = True
parameter, but this way the value is stored in the database and is only computed once, which is not what I'm looking for.
So this is not the right way of doing it.
How can one use the environnement in a <filter>
domain?
store=False
means that odoo won't store that field in db – Dachi Darchiashvili