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

Hi, everyone!

I need do something after create a recordset.

if the model is inherited some others, I can implement this by the code below:

class Diary(models.Model):
_inherit = 'diary_zqinn.diary'

description = fields.Text()
description_date = fields.Date()

@api.model
def
create(self, vals):
diary = super(Diary, self).create(vals)
'''To do after create.'''
However, if the model is non-inherited one, it will catch the Exception:

AttributeError: 'NoneType' object has no attribute 'id'
So, how to modify the code?

Thanks!

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

The create function is same for non-inherited

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Create function problem แก้ไขแล้ว
2
มิ.ย. 23
2135
Overriding method in a model แก้ไขแล้ว
1
มิ.ย. 20
35181
1
มิ.ย. 16
4593
2
ส.ค. 15
5352
1
ส.ค. 23
2944