Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
4936 Zobrazení

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
Zrušit

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

Autor Nejlepší odpověď

Solved

code:

@api.model
def create(self, vals):
po = super(PurchaseOrder, self).create(vals)
po.button_confirm()
return po
Avatar
Zrušit
Nejlepší odpověď

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
Zrušit

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

from odoo import api, fields, model

Related Posts Odpovědi Zobrazení Aktivita
1
dub 20
7745
0
úno 20
12271
4
kvě 24
13493
1
dub 24
3938
0
lis 23
2623