Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

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

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
xmlrpcreports
2 Antwoorden
9308 Weergaven
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
Annuleer
Avatar
Jérémy Kersten (jke)
Beste antwoord

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
Annuleer
Avatar
Yaidel Ferrales
Auteur Beste antwoord

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
Annuleer
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 !

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Odoo Reports
xmlrpc reports PHP
Avatar
1
feb. 24
1821
Code for page number in Body of Pdf report
reports
Avatar
Avatar
Avatar
2
okt. 25
3192
How to increase the width of a column on odoo quotation PDF?
reports
Avatar
Avatar
1
okt. 25
1009
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
1613
xmlrpc Error when attempting to connect to my local instance Opgelost
xmlrpc
Avatar
Avatar
Avatar
3
jul. 25
4207
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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