Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
4960 Widoki

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.


Awatar
Odrzuć

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

Autor Najlepsza odpowiedź

Solved

code:

@api.model
def create(self, vals):
po = super(PurchaseOrder, self).create(vals)
po.button_confirm()
return po
Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć

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

from odoo import api, fields, model

Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 20
7781
0
lut 20
12295
4
maj 24
13569
1
kwi 24
3969
0
lis 23
2662