-2
我應該做的這個功能是保存表單時保存在一個字段('niu')中的一個序列。此表單位於sale.order.line模型中。
AttributeError:'NoneType'對象沒有屬性'id'
niu = fields.Char(string="NIU", readonly=True)
@api.model
def create(self, vals):
for rec in self:
if rec.product_id.product_tmpl_id.type == 'product' and not rec.niu:
if vals.get('niu') == ' ':
vals[u'niu'] = self.env['ir.sequence'].next_by_code('sale.order.line')
result = super(SaleOrder, self).create(vals)
return result
但是,當我點擊保存按鈕,Odoo顯示我下面的錯誤: AttributeError的: 'NoneType' 對象有沒有屬性 'ID'
這究竟是爲什麼?我能做什麼? 任何幫助表示讚賞。謝謝
的可能的複製[Python的:屬性錯誤 - 「NoneType」對象有沒有屬性「東西」(http://stackoverflow.com/questions/8949252/python-attribute-error-nonetype-object-has-no-attribute-something) – tripleee
對我來說似乎不是重複的:我們不知道其他帖子指的是哪個問題 至 –