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
    • Guest House
    • Distributeur de boissons
    • Hotel
    Real Estate
    • Real Estate Agency
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consulting
    • Accounting Firm
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Metal
    • Furnitures
    • Food
    • 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
    • Solar Energy Systems
    • Cordonnier
    • Services de nettoyage
    • HVAC Services
    Others
    • Nonprofit Organization
    • 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

Odoo auto attach pdf in email

S'inscrire

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

Cette question a été signalée
wizardrmlreportsodoo
5 Réponses
19868 Vues
Avatar
Ashish Singh

Hello Guys,

I am working on timesheet module odoo of some report generation,

In Timesheet Activity Tree view  once we select any record More option will display, in More option i had put one button that call one wizard. In that wizard i had put two button one is generating report(RML Report) (list of all timesheet line based on Analytical Account).

and other button send a mail to a client of Analytical Account , Now here i get stuck that how can i automatically attach a pdf report which i had generated or it automatically generate new pdf and attach automatically in email.

0
Avatar
Ignorer
Cyril Gaspard (GEM)

Hi,do you use a template to send email ? Secondly, does your pdf is store in attachment or dynamically from where and how? bye

Avatar
Umashankar Subramani
Meilleure réponse

Hi kumar,

   First you need to create a template for your email ,settings->email->template-> create -> Name-(User defined), Applies to- description to model, model- model for creating email, and you can give acces rights, on the content tab you need create the template. In email configuration you need to configure your email address for sender and receiver. And in advanced setting you have an option that you can add a attachment automatically by giving the optional report to print or attach and save the template.

1
Avatar
Ignorer
Cyril Gaspard (GEM)

Hi, with your solution, an ir_attachment is created, but Kumar do not want this. Bye

Bertus Kruger

Thanks for this. It helped me with my missing invoice attachments. :)

Avatar
Ashish Singh
Auteur Meilleure réponse

I had made one email template for sending mail, and initially my pdf is not store in attachment, i want to add dynamically.

Means once i click a button called send email , one function call that  internally call my email template and send msg to client, but in that mail i want to also attach my pdf which  automatically( its call generate pff method and attach in email)

1
Avatar
Ignorer
Umashankar Subramani

I have tried that in Qweb report pls try this.............. https://www.odoo.com/forum/help-1/question/how-to-send-email-76125#answer-76136

Avatar
Cyril Gaspard (GEM)
Meilleure réponse

Hi,

in function you call by pushing your button, when you call method send_mail of model email_template ((module email_template), add in context all informations you need to build your pdf and id of the email in a list with key 'add_pdf': [email_id, 'file_name.pdf', ....]. for function parameter 'force_send'  set value True, then the method send of mail_mail model module mail) will be called by inheriting the context.

In this function, variable attachments contains files to send with code:


# load attachment binary data with a separate read(), as prefetching all

# `datas` (binary field) could bloat the browse cache, triggerring

# soft/hard mem limits with temporary data.

attachment_ids = [a.id for a in mail.attachment_ids]

attachments = [(a['datas_fname'], base64.b64decode(a['datas']))

for a in ir_attachment.read(cr, SUPERUSER_ID, attachment_ids,

     ['datas_fname', 'datas'])]


you should override after this code in your module by overriding method send:

+ test if key 'add_pdf' is in the context

+ if yes test email_id of the key 'add_pdf' with current email_id of function send of the for loop.

+ if yes, call your function which genarates your pdf using informations you have in key 'add_pdf' and had tuple ('file_name.pdf', file) to the variable attachments list

bye

1
Avatar
Ignorer
Ashish Singh
Auteur

Can u explain in details

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Meilleure réponse

Hi,

You can refer the blog

https://www.cybrosys.com/blog/how-to-add-email-attachments-pdf-excel-in-odoo-16

This blog provides a step-by-step guide on how to add email attachments (PDF/Excel) in Odoo 16. It includes creating a new module, defining methods to generate and return the PDF report, and sending the email with the PDF report .

Regards

0
Avatar
Ignorer
Avatar
Maduka Sopulu
Meilleure réponse

The answers provided here is for odoo 10 or below;

Here is a sample code done to generate Pdf and save to attachment using render_qweb_pdf for sending mail: 

def generate_report_file(self, id):
        pdf = self.env.ref('mymodule.action_report_labtest').render_qweb_pdf(id)[0]
        pdf = base64.b64encode(pdf)
        return pdf
So, you can return pdf as a binary to any binary field as this;
self.binary_field = self.generate_report_file(idoftherecord.id)

You can attach it to an attachment like this;
report_binary = self.generate_report_file(LabObj.id)
attachmentObj = self.env['ir.attachment'].create({
                'name': attachment_name,
                'type': 'binary',
                'datas': report_binary,
                'datas_fname': attachment_name + '.pdf',
                'store_fname': attachment_name,
                'res_model': self._name,
                'res_id': self.id,
                'mimetype': 'application/x-pdf'
            })

@Maduka Sopulu Chris 

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é
Report not working
rml reports odoo
Avatar
0
mai 15
6297
What is the difference between t-esc and t-raw ? Résolu
reports odoo
Avatar
Avatar
Avatar
2
déc. 23
61116
What are the css class available for odoo reporting ? Where we can find it ? Résolu
reports odoo
Avatar
Avatar
Avatar
3
déc. 23
20827
ODOO: ValueError: External ID not found in the system: hr_payroll.payslip_pdf
rml odoo
Avatar
Avatar
1
mars 16
16140
How do I print a report AND keep the wizard open?
wizard reports
Avatar
Avatar
1
sept. 15
4826
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