İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
4920 Görünümler

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.


Avatar
Vazgeç

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

Üretici En İyi Yanıt

Solved

code:

@api.model
def create(self, vals):
po = super(PurchaseOrder, self).create(vals)
po.button_confirm()
return po
Avatar
Vazgeç
En İyi Yanıt

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


Avatar
Vazgeç

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

from odoo import api, fields, model

İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Nis 20
7708
0
Şub 20
12267
4
May 24
13480
1
Nis 24
3934
0
Kas 23
2613