Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
4940 Vistas

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
Descartar

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

Autor Mejor respuesta

Solved

code:

@api.model
def create(self, vals):
po = super(PurchaseOrder, self).create(vals)
po.button_confirm()
return po
Avatar
Descartar
Mejor respuesta

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
Descartar

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

from odoo import api, fields, model

Publicaciones relacionadas Respuestas Vistas Actividad
1
abr 20
7755
0
feb 20
12273
4
may 24
13503
1
abr 24
3943
0
nov 23
2630