コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4536 ビュー

How to deal with binary field in odoo 10 by web service ripcord php to upload attachment files in ir.attachment table 

アバター
破棄
最善の回答

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;

アバター
破棄
関連投稿 返信 ビュー 活動
2
7月 20
27716
1
6月 23
3289
5
5月 23
15273
2
12月 23
5235
1
5月 22
2478