create(cr, uid, values, context=None)
Creates new record. This method is invoked every time click on the 'New' button and the you save trough the 'Save' button.
The parameters cr
and uid
are well known - the database cursor object and the ID of the user executing the action.
values
is a dictionary containing the values to store in the new record. The dictionary elements are in the form {'field_name': 'field_value',}
.
Let say you have a Student(osv.osv)
model with name
, fac_id
and fac_no
fields. You can create a new Student's record using the following call somewhere inside the Student
class:
new_student_id = self.create(cr, uid, {'name': 'Joe Doe',
'fac_id': 15,
'fac_no': '161832'})
write(cr, uid, ids, values, context=None)
Similar to create()
but updates existing record(s). Which records to update is defined by the ids
parameter. If you want to update the fac_id
field of students with ids 166 and 299 you can do it in the following way:
self.write(cr, uid, [166, 299], {'fac_id': 21})