Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

How to export a xml file?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
wizardexportxmldownload
3 Respostas
14600 Visualizações
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
Cancelar
Avatar
Jairo Llopis
Melhor resposta

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

0
Avatar
Cancelar
Avatar
Adrian Beloqui Beloqui
Melhor resposta

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
Cancelar
Avatar
Prakash
Melhor resposta

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
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
is there any way to export data to XML Resolvido
export xml
Avatar
Avatar
Avatar
Avatar
3
jan. 25
12353
Export/import data as XML ? v10e V10c
export xml
Avatar
0
mai. 17
393
Download file from a wizard Resolvido
wizard download content
Avatar
2
jun. 20
10659
How to export access rule to XML?
export xml v7
Avatar
Avatar
1
mar. 15
6892
ir.values,tree_but_open ,tree_but_action explanation
wizard xml openerp7
Avatar
0
mar. 15
3979
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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