跳至内容
菜单
此问题已终结

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
7714
0
2月 20
12271
4
5月 24
13490
1
4月 24
3937
0
11月 23
2622