Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

wizard to perform selection in tree view

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
wizardtreeviewselection
2 Besvarelser
26653 Visninger
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
Kassér
abdelwahed chiheb

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

Avatar
Amílcar Sánchez
Bedste svar

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

0
Avatar
Kassér
Avatar
Alkivi SAS
Forfatter Bedste svar

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
Kassér
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
sending selected records to a wizard
wizard selection
Avatar
Avatar
Avatar
2
maj 24
2391
open wizard from tree view
wizard treeview
Avatar
Avatar
1
jan. 16
7881
How to make button in tree view header always show up without selecting a record? Løst
wizard treeview button
Avatar
Avatar
Avatar
Avatar
Avatar
5
sep. 25
16058
Call an intermediate wizard on Create or Delete button in a tree view
wizard treeview v15
Avatar
0
jan. 23
2661
Create a tree selection wizard
wizard selection tree
Avatar
0
aug. 22
2988
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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