Hello electro1,
fields.Function’s are not stored on db. These are dynamic fields
Maybe you should try a fields.Float’s instead a fields.Function, and a on_change_ or an on_change_with_ function
Something like this maybe:
@fields.depends('quantity', 'gross_unit_price')
def on_change_with_t(self, name):
t = round ((Decimal(self.quantity) * Decimal(self.gross_unit_price)),2)
return t
That will replace the value of t anytime the value of quantity or gross_unit_price change
Also the getter method should never modify the data because it is often called in a readonly transaction.
If you want to cache some computed data, the best is to do it at a specific state of the Model, like it is done on Sale.confirm with Sale.store_cache.