跳至內容
選單
此問題已被標幟
1 回覆
3172 瀏覽次數

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
6月 23
2139
1
6月 20
35182
1
6月 16
4598
2
8月 15
5352
1
8月 23
2944