Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
4918 Weergaven

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
Annuleer

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

Auteur Beste antwoord

Solved

code:

@api.model
def create(self, vals):
po = super(PurchaseOrder, self).create(vals)
po.button_confirm()
return po
Avatar
Annuleer
Beste antwoord

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
Annuleer

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

from odoo import api, fields, model

Gerelateerde posts Antwoorden Weergaven Activiteit
1
apr. 20
7704
0
feb. 20
12266
4
mei 24
13474
1
apr. 24
3932
0
nov. 23
2609