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

Attach Report While Printing

S'inscrire

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

Cette question a été signalée
reportingattachmentsodoo10odoo10.0
1 Répondre
12053 Vues
Avatar
Sebin Siby

I have a report in account.invoice which have a wizard of model invoice.details.

While the report is printed I need to automatically attach the file to the attachment drop down of corresponding invoice.

How is this possible? Anyone have idea?

0
Avatar
Ignorer
Avatar
Niyas Raphy (Walnut Software Solutions)
Meilleure réponse

Hi,

For the reports  to save in the attachments button in the top of the form view, add a attachments in the report tag you have given for the report.

<report     
string="Request for Quotation"
id="report_purchase_quotation"
model="purchase.order"
report_type="qweb-pdf"
name="purchase.report_purchasequotation"
file="purchase.report_purchasequotation"
attachment="(object.name + '_test_report.pdf')"/>/>

Normally this will save the downloaded reports to  the attachments button, see Quotation /Order in sales.

For attachments button to visible in all view, install the module document(technical name)

Check whether it will work in your case.

This is a sample code for creating an attachment and it will show in attachment button in top of the form too

attachment_model = request.env['ir.attachment']
byte_str = kw['attachments[4]'].read()
uploaded_file = base64.encodestring(byte_str)
vals = {
'name': kw['attachments[4]'].filename,
'res_model': model_name,
'res_id': new_record.id,
'datas': uploaded_file}
attachments_record = attachment_model.sudo().create(vals)

Thanks

1
Avatar
Ignorer
Sebin Siby
Auteur

I have tried this and didn't worked. I have to do it from the code

Niyas Raphy (Walnut Software Solutions)

just updated the answer, check it can help you or not

Sebin Siby
Auteur

I have tried the code below. I get error showing 'my.model' object has no attribute 'custom_name'.

I am calling this function from print function in my wizard and my wizard have field 'custom_name'. Wizard is called from 'my.model' form view.

def attach_report(self):

attachment_obj = self.env['ir.attachment']

for record in self:

ir_actions_report = self.env['ir.actions.report.xml']

matching_reports = ir_actions_report.search([('report_name','=','module_name.report_template')])

if matching_reports:

report = matching_reports[0]

report_service = report.report_name

result, format = odoo_report.render_report(self._cr, self._uid, [record.id], report_service, {'model': self._name}, self._context)

eval_context = {'time': time, 'object': record}

if not report.attachment or not eval(report.attachment, eval_context):

# no auto-saving of report as attachment, need to do it manually

result = base64.b64encode(result)

file_name = re.sub(r'[^a-zA-Z0-9_-]', '_', "Report Name Here")

file_name += ".pdf"

attachment_id = attachment_obj.create({

'name': file_name,

'datas': result,

'datas_fname': file_name,

'res_model': 'my.model',

'res_id': self._context.get('active_id', False),

'type': 'binary'

})

return True

Sebin Siby
Auteur

I know how to use this. But it is attaching to the model of wizard. I want it to attach to the corresponding record from which the report is called.

<report

string="Request for Quotation"

id="report_purchase_quotation"

model="purchase.order"

report_type="qweb-pdf"

name="purchase.report_purchasequotation"

file="purchase.report_purchasequotation"

attachment="(object.name + '_test_report.pdf')"/>/>

shalin wilson

how to attach a pdf file to a report?

i just want to add spec sheet of a product to the product report

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é
Attachment Issues Odoo 10 CE
attachments odoo10
Avatar
0
janv. 19
3272
How to upload attachment in the bank statement line?
attachments odoo10.0
Avatar
0
nov. 18
3631
How to groups the same value report in QWEB Odoo Résolu
reporting group_by qweb-report odoo10 odoo10.0
Avatar
Avatar
Avatar
4
août 18
8909
Odoo10: Binary fields to file in ir.attachment
odoo10 odoo10.0
Avatar
Avatar
1
nov. 17
10998
Version 10.0: localhost refused to connect Résolu
odoo10 odoo10.0
Avatar
Avatar
Avatar
Avatar
6
déc. 23
21072
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