Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

wizard to perform selection in tree view

Naroči se

Get notified when there's activity on this post

This question has been flagged
wizardtreeviewselection
2 Odgovori
26659 Prikazi
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
Opusti
abdelwahed chiheb

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

Avatar
Amílcar Sánchez
Best Answer

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

0
Avatar
Opusti
Avatar
Alkivi SAS
Avtor Best Answer

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
sending selected records to a wizard
wizard selection
Avatar
Avatar
Avatar
2
maj 24
2393
open wizard from tree view
wizard treeview
Avatar
Avatar
1
jan. 16
7888
How to make button in tree view header always show up without selecting a record? Solved
wizard treeview button
Avatar
Avatar
Avatar
Avatar
Avatar
5
sep. 25
16082
Call an intermediate wizard on Create or Delete button in a tree view
wizard treeview v15
Avatar
0
jan. 23
2665
Create a tree selection wizard
wizard selection tree
Avatar
0
avg. 22
2991
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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