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

Hello,

I am testing how to use the external api. Here is my code in golang.
I wanted to upload a file to purchase order and create a rest api from that. However, when I tested this, there was no error. But I can't seem to find any attachments on purchase order. I also don't seem to see an attachment_ids field. But no error was generated so I am getting confused. 

By any chance, can someone help me and point me to the right direction on how to upload a file to a purchase order through the api? and then display that at least?

Thank you!


// Base64 encode the file data
fileB64 := base64.StdEncoding.EncodeToString(fileData)

models, err := xmlrpc.NewClient(fmt.Sprintf("%s/xmlrpc/2/object", url), nil)
if err != nil {
log.Fatal(err)
}

var id int64
if err := models.Call("execute_kw",
[]interface{}{
db, uid, password,
"ir.attachment", "create",
[]interface{}{
map[string]interface{}{
"res_model": "purchase.order",
"name": "Vendor Invoice",
"res_field": "pdf",
"res_id": 110,
"type": "binary",
"datas": fileB64,
},
},
}, &id); err != nil {
log.Fatal(err)
}
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,
From the code just remove the line "res_field": "pdf" and execute the function again and see if it works for you.

Also ensure from your side that the create is getting succeed

Thanks

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

thank you so much!

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

Hi, please check this: https://youtu.be/Cmbo2iGuTBY 
Hope it helps.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ย. 24
1475
2
เม.ย. 24
1957
2
มิ.ย. 24
3856
1
ต.ค. 24
895
1
ส.ค. 24
1086