Updating values of recordset records
Business logic often requires us to update records by changing the values of some of their fields. This tutorial shows you how to modify the room_no
field of the partner as we go.
Getting ready
This tutorial will use the same simplified hostel.room
definition of the Creating new records tutorial. You may refer to this simplified definition to find out about the fields.
We have the room_no
field in the hostel.room
model. For illustration purposes, we will write in this field with the click of a button.
How to do it…
- To update a room’s
room_no
field, you can write a new method calledupdate_room_no()
, which is defined as follows:def update_room_no(self): Â Â Â Â self.ensure_one() Â Â Â Â self.room_no = "RM002"
- Then, you can add a button to the room’s
<form>
view inxml
, as follows:<button name="update_room_no" string="Update Room No"...