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 do I add a button in tree view that calls a wizard and gets the ids of the records selected in the tree view?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
2 Respostas
13569 Visualizações
Avatar
Serge Mercado

In manufacturing order model, I added new buttons beside create (Produce button, and Mark as Done button). I wanted the "Produce" button to pop up a wizard that will ask for a res.user and after clicking Save button, it will write the res.user to each records. How can I make this possible?

3
Avatar
Cancelar
Sudhir Arya (ERP Harbor Consulting Services)

Where do you want to write the user record? To MRP record or consumed lines or finished product or somewhere else?

Note: To update any record, you can use write method.

Sehrish

Open wizard on button click: https://learnopenerp.blogspot.com/2020/01/open-wizard-on-button-click-in-odoo.html

Serge Mercado
Autor

Hello, Sudhir and Sehrish!

The button that I meant to describe are these buttons added above the tree view.

https://imgur.com/a/tWf2cst

<t t-extend="ListView.buttons">

<t t-jquery="button.o_list_button_add" t-operation="after">

<button t-if="widget.modelName == 'mrp.production'" class="btn btn-primary oe_produce_button" type="button" accesskey="f">Produce</button>

Serge Mercado
Autor

<blockquote class="imgur-embed-pub" lang="en" data-id="a/tWf2cst" data-context="false" ><a href="//imgur.com/a/tWf2cst"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

Serge Mercado
Autor

Please disregard my other comment.

Serge Mercado
Autor

The buttons were added using this:

https://stackoverflow.com/questions/58514381/hide-the-create-button-in-a-specific-module-only-in-odoo11

Serge Mercado
Autor

The function of that wizard will link the mrp.production to a custom model I named production.batch. Before this custom model is created, it will ask for a an attachment to be uploaded. Once I clicked save, all the records of mrp.production's field called production_batch will be filled with that of the wizard.

This is how I implemented the wizard (works on server action):

https://imgur.com/sYEVY2h

Avatar
Serge Mercado
Autor Melhor resposta

Just an update! This can now be implemented in Odoo 14 by adding a button in the header of a tree view.

<record id="my_view_id" model="ir.ui.view">
<field name="name">view.name</field>
<field name="model">my.model</field>
<field name="arch" type="xml">
<tree>
<header>
<button name="%(action_for_wizard)d" string="Action" object="action"/>
</header>
</tree>
...

When a record is selected:



When no record is selected:


3
Avatar
Cancelar
Tri Nanda

This working on Odoo14 as like what I want.

Thanks,
Tri Nanda

Niyas Raphy (Walnut Software Solutions)

Sharing a video example o the same: https://www.youtube.com/watch?v=R8eG6uOxHKw

Avatar
Paresh Wagh
Melhor resposta

Hi Serge: If I have understood your question correctly, you should be able to loop through the variable "self" that gets passed to each action to get what you need.

EDIT:

Actions can be linked to buttons in one of two ways depending on where the action is defined.

If the action is defined as a server action, you can use the following syntax:

<button name="SERVER_ACTION_ID" type="action" string="BUTTON LABEL"/>

NOTE: type="action" and name=id of the server action.

The server action id can be defined to be automatically picked up at installation time (instead of hard coding it) by using the syntax

%(EXTERNAL_ID_OF_SERVER_ACTION)d

For example,

<button name="%(stock.action_stock_report)d" type="action" string="Stock Report"/>

If the action is defined as a function in the underlying object, you can use the following syntax:

<button name="FUNCTION_NAME" type="object" string="BUTTON LABEL"/>
NOTE: type="object" and name=name of the function defined in the python class of the object
1
Avatar
Cancelar
Serge Mercado
Autor

I just realized my question is incomplete, but thank you for this Paresh! This is a step further for what I was aiming for.

Serge Mercado
Autor

Hello, Paresh! What I did that worked is that I created a server action using a wizard <act_window ... />

I was referring to this tutorial at first:

https://www.odoo.com/fr_FR/forum/aide-1/how-can-i-get-the-active-ids-from-tree-view-in-odoo-11-143922

but the multi="True" is not necessary anymore and won't work in Odoo 13, and the attribute src_model is now binding_model. This is the code I used:

<act_window id="multi_production_batch_wizard"

name="Create Production Batch"

binding_model="mrp.production"

res_model="production.batch.wizard"

view_mode="form"

target="new"

/>

I was able to retrieve the selected ids using:

manufacturing_orders = self.env['mrp.production'].browse(self._context.get('active_ids'))

Serge Mercado
Autor

It only solved half of the problem, I want to implement that server action into a new button using this:

https://stackoverflow.com/questions/58514381/hide-the-create-button-in-a-specific-module-only-in-odoo11

I don't know how to call a wizard by extending the ListView.buttons as shown here: https://imgur.com/a/tWf2cst

Paresh Wagh

Hi Serge: I have edited my earlier answer and added an explanation of how to link an action to a button.

Serge Mercado
Autor

Hello Paresh, how do I implement that if the button used is like in the link below? I added a custom ListView buttons

https://stackoverflow.com/questions/58514381/hide-the-create-button-in-a-specific-module-only-in-odoo11

Serge Mercado
Autor

Hello, Paresh! This is working now in Odoo 14 since they added a header for the tree view already. Thank you!

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
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