Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
11501 มุมมอง

Hi, 

I'm new to odoo and I want to call an API when a payment get confirmed, i mean i want to override the confirm function to call a rest API with get method, can anyone give me any example for the code or any helpful links please

Thank you

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

@api.model
def create(self, values):
record = super(ClassName, self).create(values)
import requests
username = record.username
invoice = record.invoice
credit = record.amount
payment_date= record.payment_date
response = requests.get("http://example.com?user="+ username +  "&invoice=" + invoice + "&credit=" + str(credit) + "&date=" + str(payment_date))
return record

อวตาร
ละทิ้ง
ผู้เขียน

i solved it this way, hope it's helpful to any one

คำตอบที่ดีที่สุด

Put this in your model function and should return the response

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Ali,

Where did you put this code in the ODOO interface ?

I'm trying to do it from a server action but without success .. :(

Thx

อวตาร
ละทิ้ง

Please also try posting your own question. You have asked a new question in the comment of a resolved question, so some people might not think to open the post unless they are interested in the answer to the original question.

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ค. 24
1265
2
มี.ค. 24
3489
3
ต.ค. 23
5831
0
ส.ค. 21
3105
6
ต.ค. 20
3664