Skip to Content
Menu
This question has been flagged

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
Discard

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

Author Best Answer

Solved

code:

@api.model
def create(self, vals):
po = super(PurchaseOrder, self).create(vals)
po.button_confirm()
return po
Avatar
Discard
Best Answer

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
Discard

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

from odoo import api, fields, model

Related Posts Replies Views Activity
1
Apr 20
7765
0
Feb 20
12285
4
May 24
13541
1
Apr 24
3954
0
Nov 23
2639