Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

How to export a xml file?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
wizardexportxmldownload
3 Odpowiedzi
14590 Widoki
Awatar
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
Awatar
Odrzuć
Awatar
Jairo Llopis
Najlepsza odpowiedź

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

0
Awatar
Odrzuć
Awatar
Adrian Beloqui Beloqui
Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Prakash
Najlepsza odpowiedź

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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
is there any way to export data to XML Rozwiązane
export xml
Awatar
Awatar
Awatar
Awatar
3
sty 25
12347
Export/import data as XML ? v10e V10c
export xml
Awatar
0
maj 17
393
Download file from a wizard Rozwiązane
wizard download content
Awatar
2
cze 20
10657
How to export access rule to XML?
export xml v7
Awatar
Awatar
1
mar 15
6872
ir.values,tree_but_open ,tree_but_action explanation
wizard xml openerp7
Awatar
0
mar 15
3976
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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