I am trying to get the old value of a field in onchnge method.
Here is what I tried.
@api.onchange('assigned_to')
# @api.depends('assigned_to')
def onchange_assigned_to(self):
print('onchange_assigned_to')
history = self._origin.read(["assigned_to"])
if history:
id = history[0]["assigned_to"][0]
last_assigned = self.env['res.users'].browse([id])
self.last_assign_id = last_assigned
The aboe code is working and i getting the old value only if i change the field value through GUI.
I am also changing the field value via button action., that time this function is not working.
How can I achieve this?
And I also tried on compute function with @api.depends.
That time I got an 'AttributeError: 'crm.lead' object has no attribute '_origin''