Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
11476 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

@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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

Put this in your model function and should return the response

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 24
1245
2
thg 3 24
3466
3
thg 10 23
5819
0
thg 8 21
3075
6
thg 10 20
3651