How to deal with binary field in odoo 10 by web service ripcord php to upload attachment files in ir.attachment table
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
To upload file with web service, you can convert file in base64.
You can write as following :
<?php
$url = 'your odoo url';
$db = 'your database name';
$username = 'admin';
$password = 'admin';
require_once 'ripcord/ripcord.php';
$info = ripcord::client('https://demo.odoo.com/start')->start();
$common = ripcord::client($url . '/xmlrpc/2/common');
$models = ripcord::client("$url/xmlrpc/2/object");
$b64image = base64_encode(file_get_contents('your image path'));
$uid = $common->authenticate($db, $username, $password, array());
$created_image_id = $models->execute_kw($db, $uid, $password,'ir.attachment','create',
array(
array(
'name'=>'test.png',
'datas'=> $b64image,
'datas_fname'=> 'test.png',
'res_model'=> 'res.partner',
'type'=> 'binary'
)
)
);
echo $created_image_id;
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
2
ก.ค. 20
|
27706 | ||
|
1
มิ.ย. 23
|
3281 | ||
|
5
พ.ค. 23
|
15272 | ||
|
2
ธ.ค. 23
|
5232 | ||
|
1
พ.ค. 22
|
2473 |