تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
4953 أدوات العرض

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
أبريل 20
7772
0
فبراير 20
12289
4
مايو 24
13548
1
أبريل 24
3960
0
نوفمبر 23
2640