Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
4931 Представления

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.


Аватар
Отменить

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

Автор Лучший ответ

Solved

code:

@api.model
def create(self, vals):
po = super(PurchaseOrder, self).create(vals)
po.button_confirm()
return po
Аватар
Отменить
Лучший ответ

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


Аватар
Отменить

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

from odoo import api, fields, model

Related Posts Ответы Просмотры Активность
1
апр. 20
7711
0
февр. 20
12270
4
мая 24
13487
1
апр. 24
3935
0
нояб. 23
2622