Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

Copy of PDF invoice on external storage

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
pdfinvoicesodoo v17
2 Răspunsuri
1609 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
Imagine profil
D Enterprise
Cel mai bun răspuns

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
Imagine profil
Abandonează
Imagine profil
Xavier
Autor Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Migrating to odoo 13 lost all invoice's pdf Rezolvat
pdf invoices Odoo13.0
Imagine profil
Imagine profil
Imagine profil
3
oct. 21
4284
Is it possible to add the word "PAID" anywhere on the paid invoices when I print them as PDF?
pdf templates invoices
Imagine profil
Imagine profil
2
nov. 16
5115
add borders in the pdf generated
pdf invoices purchase_order
Imagine profil
Imagine profil
1
mar. 15
4935
Download pdf in a Folder
pdf invoices xmlrpc odoo16
Imagine profil
0
aug. 24
1845
Invoices or Bills Related to Payment
pdf invoices payments bills
Imagine profil
0
iun. 23
2354
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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