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 open a record in new tab with a context ?

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
newtabcontexturlopenv15
5 Respostas
5605 Visualizações
Avatar
Dilaw bedj

Hi , please i want to know how to open a form view of another model on a new tab of the the browser by clicking on a button and passing it context

0
Avatar
Cancelar
Avatar
Yahoo Baba Innovations Pvt.Ltd
Melhor resposta

Hi  Dilaw Bej ,


It will open a new window or tab with the URL provided in the link. Here is a slightly refined version:

return {
​ 'name': 'Go to New Window',
​ 'res_model': 'ir.actions.act_url', 'type': 'ir.actions.act_url', 'url': link, # Your URL here
  ​ 'context': context, 'target': 'new', # Opens in a new window/tab }

A few things to note:

  • 'res_model': 'ir.actions.act_url' is not needed. The 'type': 'ir.actions.act_url' already specifies that it's a URL action.
  • 'context': ctx is not required unless you specifically need to pass context for this URL. If you need it, ensure that ctx is defined beforehand. If not, you can remove this part.

Let me know if you need further modifications!


Thank you

1
Avatar
Cancelar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Melhor resposta

Hi,

Let's say you have a model called model1 and you want to open a form view of another model model2 in a new tab when a button is clicked. Here are the steps:

add a button to trigger the action:

<record id="view_my_model_form" model="ir.ui.view">
    <field name="name">my.model.form</field>
    <field name="model">my.model</field>
    <field name="arch" type="xml">
        <form>
            <!-- Your existing fields go here -->
            <footer>
                <button string="Open Other Model" class="oe_highlight" type="object" name="open_other_model"/>
            </footer>
        </form>
    </field>
</record>


python :

from odoo import models, fields, api

class MyModel(models.Model):
_name =model1'

# Your existing fields go here

@api.multi
def open_other_model(self):
    # You can pass context by defining a dictionary
    context = {
        'default_field_name': 'default_value',
        'additional_context_key': 'additional_context_value',
    }

    # Open the form view of the other model in a new tab
    return {
        'name': 'Other Model Form',
        'type': 'ir.actions.act_window',
        'res_model': 'model2',
        'view_mode': 'form',
        'view_id': self.env.ref('other_module.view_other_model_form').id,  # Replace with the actual view ID
        'target': 'new',
        'context': context,
    }


Create model 2 Python and xml files 


Hope it helps

1
Avatar
Cancelar
Avatar
SunArc Technologies
Melhor resposta

Hi,

You can open record in new tab with below code if your problem still not fixed.

class YourClass1(models.Model):

    _name = 'model1'

   

    def action_open_record_new_tab(self):

        record_id = # define your record id to open record

        model = 'model2'  # Replace with the actual model name

        # Construct the URL to open the record in a new tab

        url = '/web#id=%s&model=%s' % (record_id, model)

        # You Can add context for passing values

​context = {

​ }

        # Redirect to the URL

        return {

            'type': 'ir.actions.act_url',

            'url': url,

            'target': 'new',  # Open in a new tab/window

            'context': context,

        }

 

In XML define button for method.


Thanks

0
Avatar
Cancelar
Avatar
Sun Southern
Melhor resposta

if partner has already you can use below code:

base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') url = f"{base_url}/web#id={partner_Id}&model=res.partner&view_type=form"

return { 'type': 'ir.actions.act_url', 'url': url, 'target': '_blank' }

here is my code in odoo 17 model res.partner. hope it be can help you!

0
Avatar
Cancelar
Avatar
Dilaw bedj
Autor Melhor resposta

But in this case it will open the second model as a wizard/pop-up ans not in a browser's new tab

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
Help ! How to open a view in new tab with context
newtab context open v15
Avatar
Avatar
1
jan. 24
3146
How to open a record in new tab with a context ?
newtab context record url open
Avatar
Avatar
1
jan. 24
2347
Odoo Window action apply multiple filters
context filters v15
Avatar
0
mar. 24
2444
Context group_by and order
context groupby v15
Avatar
1
out. 22
4099
Odoo 15 - pre-fill field in one2many form
form context v15
Avatar
0
ago. 22
3944
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