Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Why is my custom invoice report only being printed in the draft state and not in invoice state?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
qwebinvoicesprintingreportsodoo8.0
2 Réponses
11278 Vues
Avatar
Yenthe Van Ginneken (Mainframe Monkey)

Hi everybody

I've set up a second report for invoices. I want an alternative report option in the print dropdown so I created a second report in the account module.

I've added a report in account_report.xml under /addons/account/ like this:

        <report 
            id="account_invoices"
            model="account.invoice"
            string="Invoices"
            report_type="qweb-pdf"
            name="account.report_invoice"
            file="account.report_invoice"
            attachment_use="True"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
        />

    <!--Custom report link->
        <report 
            id="account_aangetekend"
            model="account.invoice"
            string="Aangetekende zending"
            report_type="qweb-pdf"
            name="account.report_aangetekend"
            file="account.report_aangetekend"
        />

Then I added an XML file, named report_aangetekend.xml with 95% the same code as the 'normal' report (coming from report_invoice.xml). I've only changed the names and added one field.

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_aangetekend_document">
    <t t-call="report.external_layout">
        <div class="page">
            <div class="row">
                <div class="col-xs-5 col-xs-offset-7">
                    <address t-field="o.partner_id"
                        t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' />
                    <span t-field="o.partner_id.vat"/>
                </div>
            </div>
<p>TEST</p>
<!--Lots of other, irrelevant code here-->
</div>
</t>
</template>

<template id="report_aangetekend">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'account.report_aangetekend_document')"/>
        </t>
    </t>
</template>
</data>
</openerp>

The report works, is showing up and I can print it. There is however a strange effect.
If I now create a new invoice (in draft modus) and choose the two different print options I'll get two different report prints, so far so good, as you can see here.


If I now make a second invoice, validate this and then print out the two different reports I'll get the same report twice. Both coming from the file report_invoice.xml (addons/account/views/). As you can see here:


Is there a reason why my custom report is not being printed in validated state but it is in draft? Do I have to define something more elsewhere or what am I missing?

With kind regards
Yenthe
 

0
Avatar
Ignorer
Avatar
Zbik
Meilleure réponse

Probably your report is printed from an attachment in both cases. If standard invoice state is ('open','paid') the attachment is generated, in state 'draft' no attachment.

0
Avatar
Ignorer
Yenthe Van Ginneken (Mainframe Monkey)
Auteur

@zbik that is correct, at the moment I have both set to attachment_use="True" but even if I only set one or none I still don't get the wished result. Could you give me some more details about what is wrong/how to fix it?

Zbik

Do you have removed the old attachment? In my opinion, if attachment_use="False", should work.

Zbik

My solution: https://www.odoo.com/forum/help-1/question/how-we-inherit-invoice-report-to-change-the-attachment-attribute-on-odoo-v8-69628

Yenthe Van Ginneken (Mainframe Monkey)
Auteur

@zbik even if I set both attachment_use="False" there is no difference. When the invoice is validated both versions will print the original sadly. Any more ideas / solutions?

Zbik

Erase attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')". Your code xml (deleted all attachment lines) normally working on my tmp system. I think this is an Odoo error with attachment_use="False", if attachment='xxx' not empty.

Avatar
Yenthe Van Ginneken (Mainframe Monkey)
Auteur Meilleure réponse

I've found the solution and it was very simple. I just had to set both records to attachment_use="True" and had to give them both a different name.
I have no idea why the two different names fixed it though. Those two files are added as an attachment and that seems to do the trick.

Final code:

        <report 
            id="account_invoices"
            model="account.invoice"
            string="Invoices"
            report_type="qweb-pdf"
            name="account.report_invoice"
        attachment_use="True"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            file="account.report_invoice"
        />

    <!--Custom-->
        <report 
            id="account_aangetekend"
            model="account.invoice"
            string="Aangetekende zending"
            report_type="qweb-pdf"
            name="account.report_aangetekend"
            attachment_use="True"
           <!--This one has to have a different name then the other one. The magic happens here.-->
            attachment="(object.state in ('open','paid')) and ('INV2'+(object.number or '').replace('/','')+'.pdf')"
            file="account.report_aangetekend"
        />

If you don't want any files attached under attachments there is a second solution:

        <report 
            id="account_invoices"
            model="account.invoice"
            string="Invoices"
            report_type="qweb-pdf"
            name="account.report_invoice"
        attachment_use="True"
            attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
            file="account.report_invoice"
        />

    <!--Custom-->
        <report 
            id="account_aangetekend"
            model="account.invoice"
            string="Aangetekende zending"
            report_type="qweb-pdf"
            name="account.report_aangetekend"
           <!--No attachment -->
            attachment_use="False"
            file="account.report_aangetekend"
        />

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
How to create div in QWeb that is always at the bottom of the page? Résolu
qweb reports odoo8.0
Avatar
Avatar
Avatar
Avatar
Avatar
14
mai 22
48323
Background image gets cut off on the last page of a QWeb report (Odoo8) Résolu
qweb reports odoo8.0
Avatar
1
févr. 24
6039
Printing multiple reports in one method?
qweb printing reports buttons methods
Avatar
Avatar
Avatar
Avatar
Avatar
4
nov. 22
12201
[SOLVED] Error to generate a qweb-pdf (odoo 8) Résolu
pdf qweb reports wkhtmltopdf odoo8.0
Avatar
Avatar
1
mars 15
13918
Directly printing to printer
printing reports
Avatar
Avatar
Avatar
2
mai 25
3473
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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