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

Odoo version 10 and below had an API endpoint (/xmlrpc/2/report) for retrieving invoices.

This endpoint has been removed in Odoo 11 so is there another way to retrieve invoices programmatically?

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

Note that I want to retrieve invoices in PDF format

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

I would try to use /xmlrpc/2/object with model `ir.actions.report` and method `render_qweb_pdf`. Bear in mind that you'll need a `ir.actions.report` record, because `render_qweb_pdf` isn't a "model method" (in OOP class method).

อวตาร
ละทิ้ง

Do you have a working code example please?

Unfortunately, no :-/

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

Hello,

It works for me with this script : 


<?php


$url = "url";
$db = "db";

$username = "username";
$password = "password";

if (function_exists('spl_autoload_register')) {
spl_autoload_register(function($classname){
$classfile = rtrim(__DIR__, '/') .'/'. str_replace('\\', '/', $classname) .'.php';

if (file_exists($classfile)){
require_once $classfile;
}
else {
echo $classname . ' => '. $classfile .'<br />';
exit('Une erreur est survenue...');
}
});
}

require_once('Ripcord/Ripcord.php');
$common = \Ripcord\Ripcord::client("$url/xmlrpc/2/common");
$uid = $common->authenticate($db, $username, $password, array());
$models = \Ripcord\Ripcord::client("$url/xmlrpc/2/object");

$invoice_ids = $models->execute_kw($db, $uid, $password, 'account.invoice', 'search', array(
array(
array('name', '=', '1')
)
));
$invoice_id = $invoice_ids[0];

$ctx = array('active_model' => 'account.invoice', 'active_id' => $invoice_id);
$token = $models->execute_kw($db, $uid, $password, 'portal.share', 'default_get', [[]], array('context' => $ctx))['share_link'];
$token = explode('access_token=', $token)[1];
$dl_url = "$url/my/invoices/$invoice_id?report_type=pdf&download=true&access_token=$token";
print_r($dl_url);

?>

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Anyone managed to get it to work? I also want to access the Invoice PDF using the Odoo 12 API. Any working PHP example would be very helpful!

Please help..

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello


Did you manage to have it working


Would you mind sharing


Thanks

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Odoo 11 Cash Rounding via External API. แก้ไขแล้ว
1
ธ.ค. 19
2794
1
ม.ค. 25
4318
1
พ.ย. 23
4305
1
มี.ค. 23
5783
2
ธ.ค. 19
15993