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

How to display in Odoo 9 a pdf already stored in ir.attachment DB model?

S'inscrire

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

Cette question a été signalée
pdfdisplayir.attachment
2 Réponses
8089 Vues
Avatar
Javier

Hello all,


I have a PDF file stored in table ir.attachment which looks like this in table's sql query:

"id";"create_date";"write_date";"res_model";"write_uid";"res_name";"db_datas";"file_size";"create_uid";"company_id";"index_content";"type";"public";"store_fname";"description";"res_field";"mimetype";"name";"url";"res_id";"checksum";"datas_fname"



575;"2015-12-07 17:56:51.769814";"2015-12-07 17:56:51.769814";"purchase.order";1;"PO00008...";"";25095;1;1;"(u'application',)";"binary";f;"89/8954bbeec7fda48248aa40600162dbb43adac851";"";"";"application/pdf";"salida.pdf";"";8;"8954bbeec7fda48248aa40600162dbb43adac851";"salida.pdf"



I am looking for a way to display it (ie. in a new window) when the user clicks on a button in a screen.  For that i did the following:

1. I extended purchase.order model and added do_print_stored_po as shown below:

# -*- coding: utf-8 -*-

from openerp import models, fields, api

class TodoTask(models.Model):

_inherit = 'purchase.order'

@api.one

def do_print_stored_po(self):

my_PO = self.env['ir.attachment'].search([('datas_fname', 'like', 'salida.pdf')])

return {

"type": "ir.actions.client",

"Content-Type: application/pdf\n": my_PO.db_datas

}



2. I inherited also  from purchase.purchase_order_form in the following way:

<openerp>

<data>

<record id="Purchase_Order_Extended" model="ir.ui.view">

<field name="name">Purchase Order - User extension</field>

<field name="model">purchase.order</field>

<field name="inherit_id" ref="purchase.purchase_order_form"/>

<field name="arch" type="xml">

<field name="date_order" position="after">

<button name="do_print_stored_po" type="object" string="Print stored PO" class="oe_highlight" />

</field>

</field>

</record>

</data>

</openerp>

<openerp>

<data>

<record id="Purchase_Order_Extended" model="ir.ui.view">

<field name="name">Purchase Order - User extension</field>

<field name="model">purchase.order</field>

<field name="inherit_id" ref="purchase.purchase_order_form"/>

<field name="arch" type="xml">

<field name="date_order" position="after">

<button name="do_print_stored_po" type="object" string="Print stored PO" class="oe_highlight" />

</field>

</field>

</record>

</data>

</openerp>


When app executed, it does not appear any kind of error or warning, however the screen only  trembles, but nothing happens. I expected the PDF contents would be displayed, but it isn't so.


Can anybody provide any guidance on what  should be done in this case?

I am new at developing with Odoo and may be my question is very basic, if so, I apologize in advance.


Thanks.

0
Avatar
Ignorer
Yenthe Van Ginneken (Mainframe Monkey)

@Javier, could this be a solution for you? https://www.odoo.com/apps/modules/8.0/attachment_preview/ This shows a small icon next to an attachment and when you click on it it opens a PDF in a new tab with a nice preview.

Avatar
Javier
Auteur Meilleure réponse

Yenthe, thanks for your reply. I will test it with v9 and come back to comment on results.

I appreciate your help.

 


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é
Quote Builder With Custom Rental Report (Studio)
pdf
Avatar
0
oct. 25
549
Quote Builder With Custom Rental Report (Studio)
pdf
Avatar
0
oct. 25
4
How to edit the header of the quote template Résolu
pdf
Avatar
Avatar
Avatar
2
août 25
1351
Customize Report problem Résolu
pdf
Avatar
Avatar
Avatar
3
août 25
1664
How to Edit Out the Blank Space in the Quote/Order Confirmation PDFs? Résolu
pdf
Avatar
Avatar
Avatar
Avatar
3
août 25
2773
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