Skip to Content
Menu
This question has been flagged
1 Reply
2985 Views

Hi guys,

           I need to add search filter for computed boolean field,If i add store =  True,The computed function doesnt work,I tried adding search method in the field,but it doesnt work too.Please help

Avatar
Discard
Best Answer

Hello, 

When the store attribute is equal to True it needs it will be stored in the database. When stored is equal to False the computed field is calculated on the fly. So when stored is False you will see the value as the record loads into the view. 

When store is True you need to change the fields in the depends decorator to see a change in the field. Sof to this example: 

from odoo import api
total = fields.Float(compute='_compute_total', store=True)
@api.depends('value', 'tax')
def _compute_total(self):
    for record in self:
        record.total = record.value + record.value * record.tax

Only when the fields "value" or "tax" are changed your field will display the correct value. I would suggest doing a mass update of the fields that depend on your computed field. 

I hope this helps, 

Avatar
Discard