So i have this field, basically, it computes the subtotal of the product using the unit price and quantity:
pr_subtotal = fields.Float(
string="Subtotal",
compute='_compute_subtotal',
store=True
)
And here is the compute function:
@api.onchange('qty', 'unit_price')
def _compute_subtotal(self):
for record in self:
record.pr_subtotal = record.qty * record.unit_price
However, when i am saving it keeps reseting to 0. Am i missing something?