Hi all!
I have a model with a field that I want to constantly change.
This my model:
class TestModel(models.Model):
_name = 'test'
device = fields.Char(string="Device")
time = fields.Char()
lastTime = fields.Char()
In the controller I get the record id and the new lastTime value:
def edit(self, **rec):
try:
alert_last_time = request.env['test'].search([], limit=1)
alert_last_time.lastTime = rec['lastTime']
alert_last_time.write({'lastTime': rec['lastTime']})
except KeyError:
return {'success': False,
'message': 'KeyError'}
else:
return {'success': True,
'message': 'Record was successfully updated'}
If I create several records and try to change them, the first created record changes, but how to make the record whose id I have specified change, I do not yet understand