Skip to Content
Menu
This question has been flagged
4 Replies
10934 Views

Hi,

I'm importing our supplier invoices from another software through API (XML-RPC).
I need to attach the scan PDF for each invoice.


I can't find any documentation about this on the Web.

Do somebody already make it ?


Thanks 

Avatar
Discard
Best Answer

i might be a bit late, but you simply have to encode it in b64 ;)    


Avatar
Discard
Best Answer

I am using this code to upload image to ir.attachment for product.template and it works for me. Hope it will help. Odoo will automatically add records for image_medium and image_small.


   $imageBase64 = base64_encode(file_get_contents('path_to_your_file/image.png'));
$models->execute_kw($db, $uid, $password,
'ir.attachment',
'create', // Function name
array( // Values-array
array( // First record
'res_model'=>'product.template',
'name' => 'image',
'res_field' => 'image',
'res_id'=> 1234,
'res_name' => 'product_name',
'type' => 'binary',
'datas' => $imageBase64
)
)
);
Avatar
Discard
Author Best Answer

Sorry my question wasn't clear...

I'm already using the odoo webservice..


The only question i had is to create an attachement i need to request as the following:

$param = array(array(

            'res_model'=>'account.invoice',

            'res_id'=>95,

            'name' => 'myattachement.pdf',

            'datas' => '????'

        ));



  $id = $models->execute_kw($db,$uid,$password,

        'ir.attachment',

        'create',

        $param);


My question is How to pass the data ? 

Avatar
Discard