I am developing a webservice in OpenERP 7 that create a new partner on the res_partner table with a POST method. My problem is that the create()
method return me the new object ID, but the database is not updated.
Here is my code:
@openerpweb.httprequest
def add_partner(self, req, db, user, password, name, type, street, city, zip, phone, email, function):
uid = req.session.authenticate(db, user, password)
osv_pool = pooler.get_pool(db)
cr = pooler.get_db(db).cursor()
partner_pool = osv_pool.get('res.partner')
partner_dict = {
'name': name,
'type': type,
'street': street,
'city': city,
'zip': zip,
'phone': phone,
'email': email,
'function': function
}
result = partner_pool.create(cr, uid, partner_dict)
cr.close()
return str(result)
The method doesn't give me any error, and the request return a 200 code, with the new ID. I can't find why the database is not being updated in this create method
I have found the problem. I needed to commit the changes on the cursor object, so I used cr.commit()
and succesfully added the entry on the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With