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

[SOLVED] Generate empty PDF in Odoo 16

Odoberať

Get notified when there's activity on this post

This question has been flagged
pdfreportpdfreportodoo16features
2 Replies
6897 Zobrazenia
Avatar
Oleg Zubak

Hi 

I have a pice of code what I use to get a PDF byte string which is created when I try to generate a PDF Document from 'account_move' module. 

But the problem is that PDF file is empty. I take only metadata of the file.

```

​ ​ ​ ​import base64
import datetime
import os
import threading

from dotenv import load_dotenv
from odoo.http import request
from odoo.tools.config import config
from odoo.tools import pdf
from telebot import apihelper, types

from odoo import SUPERUSER_ID, api, fields, http, models, sql_db, _

from . import bot_controller


class AccountMove(models.Model):
​_inherit = 'account.move'
 
 
​automatic_send = fields.Char(compute='auto_send_invoice')
​pdf_file = fields.Binary(string="PDF File", readonly=True)
 
​@api.constrains('state')
​def auto_send_invoice(self, ): ​
​ ​if self.state == 'posted' and self.move_type == 'out_invoice' and : ​ ​ ​ ​self.env['ir.actions.report']._get_report_from_name('telegram_bot_module.report_tg')

​ ​pdf_content = report._render_qweb_pdf(report.id)
 
​ ​invoice_name = f"invoice_{self.id}.pdf"

 
​ ​with open('invoice_from_action.pdf', 'wb') as file:
​ ​ ​file.write((pdf_file[0]))rning(f"PDF content: {(report)}")
 

 

```

1
Avatar
Zrušiť
Avatar
Oleg Zubak
Autor Best Answer

[Solved] by using next code:

report = self.env['ir.actions.report'].sudo()._get_report_from_name(
'account.report_invoice_with_payments')

pdf_file = report._render_qweb_pdf(report.id, record.id)
pdf_file = pdf_file[0]
record.pdf_file = base64.b64encode(pdf_file)

0
Avatar
Zrušiť
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello Oleg Zubak,

I think you have passed wrong id in report. 

Please find code in comment. 

Hope it will be helpful to you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

0
Avatar
Zrušiť
Jainesh Shah(Aktiv Software)

Please find code here :-

pdf_content = report._render_qweb_pdf(report.id)

In report._render_qweb_pdf you have passed report's report.id instead of current record id(account.move)
Here, you can see how to pass current id for any report
In pdf_content you will get complete rendered report

@api.constrains('state')
def auto_send_invoice(self, ):
if self.state == 'posted' and self.move_type == 'out_invoice':
report = self.env['ir.actions.report']
pdf_content = report._render_qweb_pdf('telegram_bot_module.report_tg', res_ids=self.id)

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
How to use bootstrap 4 when creating report pdf? Solved
pdf report bootstrap odoo16features
Avatar
Avatar
1
feb 24
3471
Odoo16.2 - boxed - quotation pdf page2 - header is cropped Solved
pdf quotation pdfreport odoo16features
Avatar
Avatar
1
aug 23
3621
One document has header and footer second one does not v16 Solved
pdf reporting pdfreport odoo16features
Avatar
Avatar
1
mar 23
4191
PDF reports Solved
pdf report
Avatar
Avatar
Avatar
Avatar
Avatar
5
júl 25
3290
How can i print my invoice from a server action
pdf invoice report serveraction odoo16features
Avatar
0
mar 24
2218
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