Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1044 มุมมอง

Hello Odoo Gurus

Using a controller in 17 community to try some stuff out. Can anyone tell me why:

request.env['installers.installers'].create({ 'notes': kw.get('update')})

works fine, but:

request.env['installers.installers'].write({'id': int(installers_id.id), 'notes': kw.get('update')})

does not?

I want to update an existing record. There are not errors reported and the logs are clean. Not much to go on. Record 1 exists.

The variables:

installers_id=1

kw.get('update') = "some random text"

The notes field is Char. 

I suspect there is something very obvious I am complete missing here. 

TIA.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I need to learn Odoo ORM. To write one or multiple record, it need to have record set. In your code request.env['installers.installers'] doesn't contain any record at all. Instead you may use:
request.env['installers.installers'].browse(int(installers_id.id)).write({'notes': kw.get('update')})

อวตาร
ละทิ้ง
ผู้เขียน

Ah, of course! Good call Dươn. Thank you so much.

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 23
2026
1
มิ.ย. 21
3865
0
พ.ย. 22
2187
1
ก.ค. 23
5215