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

wizard to perform selection in tree view

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
wizardtreeviewselection
2 Respostas
26684 Visualizações
Avatar
Alkivi SAS

Hi there,

I'm trying to create a wizard, that display a list (tree view). User will then pick the wanted element and the wizard will return it to perform some action.

I'm able to create the wizard, perform the search to obtain the list, but I'm unable to catch the selection for a specific element in the tree view.

Any idea how to do that ?

Thanks !

5
Avatar
Cancelar
abdelwahed chiheb

Hi Alkivi, could you please show us your code to help u ! Thanks

Avatar
Amílcar Sánchez
Melhor resposta

Did you fix this? I'm having the same problem

0
Avatar
Cancelar
Avatar
Alkivi SAS
Autor Melhor resposta

Hi there,

sorry about the delay ... Just started to work again on this. Overall, the technic seems OK, but here is my current issue.

On the wizard, I have a tree with several objects. User need to pick the correct one (a button seems appropriate) and then some action is performed, linking the source object (the one the wizard comes from) and the destination object (the user choice).

I'm thinking about creating an inherited object for the destination object with an extra method matching my exact needs. Any advice ? The more I go forward, the more I created complexity. I'd like a simple and elegant solution to that ;)

Cheers

Here is some code

The transaction view form (goal: launch wizard)

    <record model="ir.ui.view" id="view_linxo_transaction_form">
        <field name="name">linxo.transaction.form</field>
        <field name="model">linxo.transaction</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Transaction Info">
                <group colspan="4" col="2">
                    <field name="date" readonly="1"/>
                    <field name="label" readonly="1"/>
                    <field name="notes" readonly="1"/>
                    <field name="amount" readonly="1"/>
                    <field name="account_move_line_id"  attrs="{'invisible':[('account_move_line_id','=',False)]}" />
                    <field name="journal_id" readonly="1"/>
                </group>
                <button name="open_wizard"
                    string="Reconcile Wizard"
                    type="object"
                    help="Find associated movement" attrs="{'invisible':[('account_move_line_id','!=',False)]}"
                    class="oe_highlight" />
            </form>
        </field>
    </record>

Now the open_wizard method :

def open_wizard(self, cr, uid, ids, context=None):
    if context is None:
        context = {}
    if not ids:
        return False
    if not isinstance(ids, list):
        ids = [ids]

    transaction = self.browse(cr, uid, ids, context=context)[0]

    vals = { 'transaction_id': ids[0], 'date': transaction.date }
    if transaction.amount > 0:
        vals['debit'] = transaction.amount
    else:
        vals['credit'] = -transaction.amount

    wizard_id = self.pool.get('linxo.reconcile').create(cr, uid, vals=vals, context=context)
    return {
        'name': 'Reconcile Wizard',
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': 'linxo.reconcile',
        'res_id': wizard_id,
        'type': 'ir.actions.act_window',
        'target': 'new',
        'context': context,
    }

The wizard class :

class linxo_reconcile(osv.osv_memory):
    _name='linxo.reconcile'

    def _get_candidates(self, cr, uid, ids, field_name, arg, context):
        """Will return a list of ids according to the match
        """
        result = {}

        wizard = self.browse(cr, uid, ids, context=context)[0]
        wizard_id = ids[0]

        transaction = wizard.transaction_id
        if not transaction:
            return result

        _logger.debug('Got transaction %d' % transaction.id)

        search_args = [
            #('date', '=', wizard.date),
            ('journal_id', '=', transaction.journal_id.id),
        ]

        if wizard.credit:
            search_args.append(('credit', '=', wizard.credit))
        else:
            search_args.append(('debit', '=', wizard.debit))

        _logger.debug('Search criteria for account.move.line')
        _logger.debug(search_args)

        account_ids = self.pool.get('account.move.line').search(cr, uid, search_args, context=context)
        _logger.debug('Search result for account.move.line')
        _logger.debug(account_ids)

        if account_ids:
            result[wizard_id] = account_ids
        else:
            #res[i] must be set to False and not to None because of XML:RPC
            # "cannot marshal None unless allow_none is enabled"
            result[wizard_id] = False

        return result

    _columns = {
        'date': fields.date('Date'),
        'debit': fields.float('Debit', digits_compute=dp.get_precision('Account')),
        'credit': fields.float('Credit', digits_compute=dp.get_precision('Account')),
        'transaction_id': fields.many2one('linxo.transaction', 'Original Transaction'),
        'candidates' : fields.function(_get_candidates, type='one2many', obj='account.move.line', method=True, string='Matching Transactions'),
    }

And finally, the wizard view :

    <record model="ir.ui.view" id="view_linxo_reconcile">
        <field name="name">linxo.reconcile.view</field>
        <field name="model">linxo.reconcile</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Reconciliation Wizard" version="7.0">
                <group string="Search criteria" col="4">
                    <field name="date" readonly="1" />
                    <field name="debit" readonly="1" />
                    <field name="credit" readonly="1" />
                </group>
                <separator string="Candidates" colspan="4"/>
                <field name='candidates'>
                    <tree string="Matching candidates">
                        <field name="date" readonly="1" />
                        <field name="debit" readonly="1" />
                        <field name="credit" readonly="1" />
                        <field name="state" readonly="1" />
                        <field name="partner_id" readonly="1" />
                    </tree>
                </field>
               <footer>
                   <button string="Cancel" special="cancel"/>
               </footer>
            </form>
        </field>
    </record>
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
sending selected records to a wizard
wizard selection
Avatar
Avatar
Avatar
2
mai. 24
2428
open wizard from tree view
wizard treeview
Avatar
Avatar
1
jan. 16
7919
How to make button in tree view header always show up without selecting a record? Resolvido
wizard treeview button
Avatar
Avatar
Avatar
Avatar
Avatar
5
set. 25
16182
Call an intermediate wizard on Create or Delete button in a tree view
wizard treeview v15
Avatar
0
jan. 23
2711
Create a tree selection wizard
wizard selection tree
Avatar
0
ago. 22
3041
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