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

When purchase order created that time automatic confirm purchase order.

code:

@api.model
def create(self, vals):
res = super(PurchaseOrder, self).create(vals)
res.button_confirm()

Error:

AttributeError: 'NoneType' object has no attribute 'id'


can you please help me, how to do that auto-confirm purchase order?

Thanks.


頭像
捨棄

Which model did you add this code to? I'm trying to autoconfirm POs and cant find where to put this code.

作者 最佳答案

Solved

code:

@api.model
def create(self, vals):
po = super(PurchaseOrder, self).create(vals)
po.button_confirm()
return po
頭像
捨棄
最佳答案

Hi Kahmul,


How did you do this in odoo 16? i trie to at this code and it tells me 


NameError: name 'api' is not defined


頭像
捨棄

Hi,
In header of the python script of your model:

from odoo import api, fields, model

相關帖文 回覆 瀏覽次數 活動
1
4月 20
7776
0
2月 20
12289
4
5月 24
13552
1
4月 24
3962
0
11月 23
2641