Updating values of recordset records
Business logic often requires us to update records by changing the values of some of their fields. This recipe shows you how to modify the date
field of the partner as we go.
Getting ready
This recipe will use the same simplified library.book
definition of the Creating new records recipe. You may refer to this simplified definition to find out about the fields.
We have the date_release
field in the library.book
model. For illustration purposes, we will write in this field with the click of a button.
How to do it...
- To update a book's
date_updated
field, you can write a new method calledchange_update_date()
, which is defined as follows:def change_release_date(self): self.ensure_one() self.date_release = fields.Date.today()
- Then, you can add a button to the book's
<form>
view inxml
, as follows:<button name="change_release_date" string="Update...