I have to set a field that compute the difference between the old and the new value of a float field, I defined an auxiliary field that contain the old value, but the problem that the value of auxiliary field replaced by the new value then the diff always Zero.
@api.multiAnd when wereplace the order of line of the fuction we will have a problem : field used before calculated.
def _computeVar(self): for record in self:
record .val_aux= record .val
record .val_diff= record .val-record.val_aux
val=fields.Float(string='val')
val_aux=fields.Float(string='val aux',compute='_computediff', readonly=True) val_diff= fields.Float(string='val diff',compute='_computediff', readonly=True)
How to solve this problem
you cant calculate them because your fields are readonly as i think