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

Copy of PDF invoice on external storage

Odoberať

Get notified when there's activity on this post

This question has been flagged
pdfinvoicesodoo v17
2 Replies
1620 Zobrazenia
Avatar
Xavier

Hi,

I try to automate the creation of reccuring invoices. I manage to create the invoice, send it by mail using my template with the pdf attached. 
Now I try to copy the Pdf file on a nextcloud instance. The connection is Ok, I managed to create the folders but my issue is : when I generate the pdf file, the corresponding invoice is deleted. 
Here is my code : 


from odoo import models, fields, api
import base64
import requests
import locale
import logging
from urllib.parse import quote
_logger = logging.getLogger(__name__)

class AccountMove(models.Model):
    _inherit = 'account.move'

    @api.model
    def envoyer_quittance_et_sauvegarder(self):
      # ID du modèle de facture à copier
        facture_modele_id = 16
        facture_modele = self.env['account.move'].browse(facture_modele_id)

        # Dupliquer et valider
        nouvelle_facture = facture_modele.copy()
        nouvelle_facture.action_post()
        # Envoi par mail
        template = self.env.ref('quittance.modele_email')
template.send_mail(nouvelle_facture.id, force_send=True)

""" Code about construction of the Url and Nextcloud authentication """

# Générer le PDF
        report = self.env['ir.actions.report']._get_report_from_name('account.report_invoice')
        pdf_content, _ = report._render_qweb_pdf(nouvelle_facture.id)
       
        # Envoyer le PDF sur Nextcloud
        response = requests.put(
            url_pdf,
            data=pdf_content,
            auth=(username, password),
            headers={'Content-Type': 'application/pdf'}
        )

        if response.status_code not in (200, 201, 204):
            _logger.warning(f" Erreur envoi PDF : {response.status_code} - {response.text}")
        else:
            _logger.info(f" Quittance enregistrée : {pdf_filename} dans {url_quittances}")


Is there another way for creating a pdf file?

0
Avatar
Zrušiť
Avatar
D Enterprise
Best Answer

try:

    report = self.env['ir.actions.report'].search([('model', '=', 'account.move')], limit=1)

    if not report:

        _logger.error("Aucun rapport trouvé pour le modèle account.move")

        return


    pdf_content, _ = self.env['ir.actions.report']._render_qweb_pdf(report.report_name, [nouvelle_facture.id}")


    # Upload to Nextcloud

    response = requests.put(

        url_pdf,

        data=pdf_content,

        auth=(username, password),

        headers={'Content-Type': 'application/pdf'}

    )


    if response.status_code not in (200, 201, 204):

        _logger.warning(f"Erreur envoi PDF : {response.status_code} - {response.text}")

    else:

        _logger.info(f"Quittance enregistrée : {pdf_filename} dans {url_quittances}")


except Exception as e:

    _logger.error(f"Erreur lors de la génération ou l'envoi du PDF : {e}")


0
Avatar
Zrušiť
Avatar
Xavier
Autor Best Answer

Is there only a way to send a pdf file to any storage?

Edit : Yes! 

Replace the code after # Générer le PDF by : 

# Générer le PDF
        try:
            report = self.env['ir.actions.report'].search([('model', '=', 'account.move')], limit=1)
            if not report:
                _logger.error("Aucun rapport trouvé pour le modèle account.move")
                return

            pdf_content, _ = self.env['ir.actions.report']._render_qweb_pdf(
                report.report_name, nouvelle_facture.ids
            )
            _logger.info(f"PDF généré pour la facture ID {nouvelle_facture.id}")
        except Exception as e:
            _logger.error(f"Erreur lors de la génération du PDF pour facture ID {nouvelle_facture.id} : {e}")
            return
0
Avatar
Zrušiť
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
Migrating to odoo 13 lost all invoice's pdf Solved
pdf invoices Odoo13.0
Avatar
Avatar
Avatar
3
okt 21
4295
Is it possible to add the word "PAID" anywhere on the paid invoices when I print them as PDF?
pdf templates invoices
Avatar
Avatar
2
nov 16
5126
add borders in the pdf generated
pdf invoices purchase_order
Avatar
Avatar
1
mar 15
4943
Download pdf in a Folder
pdf invoices xmlrpc odoo16
Avatar
0
aug 24
1850
Invoices or Bills Related to Payment
pdf invoices payments bills
Avatar
0
jún 23
2357
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