Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How do I get a PDF of an Invoice via PHP?

Odoberať

Get notified when there's activity on this post

This question has been flagged
xmlrpcreports
2 Replies
9295 Zobrazenia
Avatar
Yaidel Ferrales

I'm trying to get an invoice in it's pdf version , but the example en the docs only guide me to this result:

array (size=2)
  'faultCode' => int 2
  'faultString' => string 'None' (length=4)

I've been trying to find what the faultCode 2 means but no luck at all. Can you provide me any working example or documentation? I'm using this source code:

<?php

require_once('ripcord.php');

$url = "http://xxx.viennaresidence.com";

$db = "odoo.yaidel";

$username = "development@worldwideresidence.com";

$password = "xxx";

$common = ripcord::client("$url/xmlrpc/2/common");

$uid = $common->authenticate($db, $username, $password, array());

$models = ripcord::client("$url/xmlrpc/2/object");

$invoice_ids = $models->execute_kw(

$db, $uid, $password,

'account.invoice', 'search',

array(

array(

array(

'type',

'=',

'out_invoice'

),

array(

'state',

'=',

'open'

)

)

)

);

/*

var_dump($models->execute_kw(

$db, $uid, $password,

'ir.actions.report.xml', 'fields_get',

array(),

array('attributes' => array('string', 'help', 'type'))

));

*/

echo "<b>Invoices Opened</b>";

var_dump($invoice_ids);

$report = ripcord::client("$url/xmlrpc/2/report");

/*

echo "<b>Report XMLRPC Object</b>";

var_dump ($report);

*/

$result = $report->render_report(

$db, $uid, $password,

'account.report_invoice', 8);

/*

echo "<b>Report XMLRPC Object after Call</b>";

var_dump ($report);

*/

echo "<b>Result of calling the Render Report</b>";

if (isset($result['faultCode'])) {

var_dump($result);

} else {

$report_data = base64_decode($result['result']);

}

?>

Thanks in advance.

1
Avatar
Zrušiť
Avatar
Jérémy Kersten (jke)
Best Answer

Hello, I have just tested on 9.0 and master and it works without any problem.


Could you check your log to see the tracebackthat is raised... ?


Here my test on runbot.


<?php
    // V9
$url = "http://148681-9-0-7f9942-all.runbot8.odoo.com";
$db = "148681-9-0-7f9942-all";

// master
$url = "http://148647-master-6a4306-all.runbot9.odoo.com";
$db = "148647-master-6a4306-all";

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

require_once('ripcord.php');
$common = ripcord::client("$url/xmlrpc/2/common");
$uid = $common->authenticate($db, $username, $password, array());
$models = ripcord::client("$url/xmlrpc/2/object");
$invoice_ids = $models->execute_kw($db, $uid, $password, 'account.invoice', 'search', array(
array(
array('type', '=', 'out_invoice'),
array('state', '=', 'open')
)
));
$report = ripcord::client("$url/xmlrpc/2/report");
$result = $report->render_report($db, $uid, $password, 'account.report_invoice', array($invoice_ids[0]));
$report_data = base64_decode($result['result']);
header('Content-Type: application/pdf');
echo $report_data;
?> 

UPDATE MY PREVIOUS ANSWER

After some investigations in your database, it appears that you customize the report invoice and delete the default one. So 'account.report_invoice' doesn't exists anymore and has been replaced by report 'customized_invoice.invoice_report'.

You probably have some tracebacks in your log with msg like "ValueError: "Required report does not exist: account.report_invoice" "  :)

So just replace:

$result = $report->render_report($db, $uid, $password, 'account.report_invoice', array($invoice_ids[0]));

by

$result = $report->render_report($db, $uid, $password, 'customized_invoice.invoice_report', array($invoice_ids[0]));

And it should work... like a charm


1
Avatar
Zrušiť
Avatar
Yaidel Ferrales
Autor Best Answer

Thanks, for the reply. Just as you said, the problem was the template. I changed the account.invoice and I got my first PDF. So once again thank you.

0
Avatar
Zrušiť
Jérémy Kersten (jke)

Hello Seems that I forgot to post my last answer :( But after some investigations, I found the error ... You have renamed the default report 'account.report_invoice' by customized_invoice.xxx! So the error was because it doesn't find the report name !

Jérémy Kersten (jke)

I find it... So I have uptaded the previous answer. Have fun with Odoo !

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Odoo Reports
xmlrpc reports PHP
Avatar
1
feb 24
1818
Code for page number in Body of Pdf report
reports
Avatar
Avatar
Avatar
2
okt 25
3189
How to increase the width of a column on odoo quotation PDF?
reports
Avatar
Avatar
1
okt 25
997
Odoo Online (SaaS 18.4 Enterprise) – How to modify invoice report header without affecting other reports but keep default table content
reports
Avatar
Avatar
1
aug 25
1605
xmlrpc Error when attempting to connect to my local instance Solved
xmlrpc
Avatar
Avatar
Avatar
3
júl 25
4199
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now