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 export a xml file?

S'inscrire

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

Cette question a été signalée
wizardexportxmldownload
3 Réponses
14594 Vues
Avatar
Anabela Damas

Hi,

I'm trying to export an xml file that I done the function that generate this file, but I wanted that when I click on the button "generate xml" this will generate the file and do the download of the file.

The download part I just can if I go to the form of the object containing the filedata field.

I've like this :

class my_class(osv.osv_memory):

    _name = "my.class"
    _columns = {
            'name': fields.char('Filename', 16, readonly=True),
            'filedata': fields.binary('File', readonly=True),
           }

    def generate_xml(self, cr, uid, ids, context=None):
        ..... compute data to write in xml...
        xml_data = text_to_write_in_xml
        file=base64.encodestring( xml_data )
        return self.write(cr, uid, ids, {'state':'get', 'filedata':file, 'name':"file.xml"}, context=context)

     <record id="wizard_file" model="ir.ui.view">
            <field name="name">Xml File export</field>
            <field name="model">my.class</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form col="3" string="xml" >
                                ....
                                <button icon="gtk-ok" name="generate_xml"  string="Generate xml" type="object"/>
                               ....
               </form>
            </field>
        </record>

With this code the file is created and the wizard close. If I want the file I've to go to the list of all records of the object my.class and click "Download". I want to make the download when click in the button generate_xml. How do I do that?

As an option I try to keep the wizard open in the record that I had created the file ... but I just manage to go to a form to create a new record, I couldn't stay in the record that I was before click in "generate xml". I tried this way :

 def generate_xml(self, cr, uid, ids, context=None):
    ..... compute data to write in xml...
    xml_data = text_to_write_in_xml
    file=base64.encodestring( xml_data )
    self.write(cr, uid, ids, { 'filedata':file, 'name':"file.xml"}, context=context)
    return {
        'type': 'ir.actions.act_window',
        'res_model': 'my.class',
        'view_mode': 'form',
        'view_type': 'form',
        'target': ids, 
        'context': dict(context, active_ids=ids)
        }
1
Avatar
Ignorer
Avatar
Jairo Llopis
Meilleure réponse

You need a Controller for that. See example in source of mail.message.

0
Avatar
Ignorer
Avatar
Adrian Beloqui Beloqui
Meilleure réponse

Hi Anabela,

Did you solve this problem? I am trying to create a custom xml file using some of the information from the fields of my module, but I just can find the right information in order to have a guide of how to achieve this. I hope you can help me.

Thanks

0
Avatar
Ignorer
Avatar
Prakash
Meilleure réponse

In the Python return type add 'target':'new' it allow to download in the wizard pop-up itself.

return {
        'type': 'ir.actions.act_window',
        'res_model': 'my.class',
        'view_mode': 'form',
        'view_type': 'form',
        'target': ids,
        'context': dict(context, active_ids=ids)
        'views': [(False, 'form')],
        target': 'new',
        }
        

In the xml file add filename tag it allow to download with filename.

<field name="data" filename="name"/>   

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é
is there any way to export data to XML Résolu
export xml
Avatar
Avatar
Avatar
Avatar
3
janv. 25
12350
Export/import data as XML ? v10e V10c
export xml
Avatar
0
mai 17
393
Download file from a wizard Résolu
wizard download content
Avatar
2
juin 20
10657
How to export access rule to XML?
export xml v7
Avatar
Avatar
1
mars 15
6881
ir.values,tree_but_open ,tree_but_action explanation
wizard xml openerp7
Avatar
0
mars 15
3977
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