Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

How can I use a search view into a view displayed by a button ?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
actionviewsearchtreebutton
1 Respondre
17862 Vistes
Avatar
PJ Soule

Hi everyone.

I'm new to OpenERP, and I experience some issue to display a view by clicking on a button from another view (creating an ir.action.act_window object). I can display the view that I want to, but the search view isn't available.

When I display the view from a menu link, no problem, my search view appears and is functional.

Here the XML for the tree I want to display and my search view :

<!-- Search view -->
     <record id="view_search_result_filter" model="ir.ui.view">
        <field name="name">Filtres des résultats</field>
        <field name="model">flights.result</field>
        <field name="arch" type="xml">
            <search string="Résultats">
                <group expand="1" string="Group By...">
                    <filter name="solu" string="Solution" domain="[]" context="{'group_by':'solution_name'}"/>
                    <filter name="traj" string="Trajet" domain="[]" context="{'group_by':'journey_name'}"/>
                </group>
            </search>
        </field>
    </record>

    <!-- Tree view -->
    <record id="flights_result_tree" model="ir.ui.view">
        <field name="name">flights.result.tree</field>
        <field name="model">flights.result</field>
        <field name="arch" type="xml">
            <tree string="Résultats">
                <field name="solution_name" invisible="1" />
                <field name="solution_number" invisible="1" />
                <field name="source" />
                <field name="airline" />
                <field name="fare" />
                <field name="fare_type" />
                <field name="private_fare" />
                <field name="journey_number" invisible="1"  />
                <field name="journey_name"  invisible="1" />
                <field name="alternative_number"  invisible="1" />
                <field name="alternative_name"  invisible="1" />
                <field name="alternative_departure_datetime" />
                <field name="alternative_arrival_datetime" />
                <field name="alternative_stops" />
                <field name="alternative_technical_stops" />
                <field name="alternative_departure_airport" />
                <field name="alternative_arrival_airport" />
          </tree>
        </field>
    </record>

And here is the code of the button which display my view :

def flight_open_results(self, cr, uid, ids, context=None):
    this = self.browse(cr, uid, ids, context=context)[0]
    tree_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'app_flights', 'flights_result_tree')[1]
    search_view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'app_flights', 'view_search_result_filter')[1]
    form_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'app_flights', 'flights_result_form')[1]

    res = {
        'type': 'ir.actions.act_window',
        'name': 'Résultats',
        'view_type': 'tree',
        'view_mode': 'tree,form',
        'res_model': 'flights.result',
        'domain':[('search_id','=',this.id)],
        'context':{'search_default_Current': 1, 'search_default_solu': 1, 'search_default_traj':1},
        'views': [(tree_id,'tree'),(form_id,'form')],
        'search_view_id': search_view_id
    }

    return res

And to finish, my menu link, which works well :

    <record model="ir.actions.act_window" id="action_flights_results">
        <field name="name">Résultats</field>
        <field name="res_model">flights.result</field>
        <field name="view_type">form</field>
        <field name="domain">[]</field>
        <field name="view_mode">form,tree</field>
        <field name="view_id" ref="flights_result_tree" />  
        <field name="context">{'search_default_Current': 1, 'search_default_solu': 1, 'search_default_traj':1}</field>
    </record>

    <menuitem name="Résultats"
        parent="menu_engine_flights"
        id="menu_engine_flights_results"
        action="action_flights_results"/>

As you see, I added a form view to make some tests, and :

  • From the "normal" view, opened with a menu link, everything works fine : I can click on a line, my form view shows, with controls to navigate between elements on the top of the page.

  • From the view opened from the button, when I click on a line of my tree, nothing happens. And when I switch to the form view, there is no record loaded and I don't have any navigation control, only the possibility to create a new record.

I think this is a lead to the answer, but I don't know OpenERP weel enough to find the solution. Could you help me with this please ?

Thank you.

1
Avatar
Descartar
Avatar
Andreas Brueckl
Best Answer

In the return value of flight_open_results you should change the view_type from tree to form.

Also the view_mode ('tree,form') is different to that defined in action_flights_results ('form, tree').

2
Avatar
Descartar
PJ Soule
Autor

It works, thanks ! I'm really a newbie into the openERP world, and I dn't really understand why I have to call the form view to show the tree view, but though, it works, and that's all I needed. Thank you again !

Enjoying the discussion? Don't just read, join in!

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

Registrar-se
Related Posts Respostes Vistes Activitat
button on top of tree view
v6.1 view tree button
Avatar
0
de març 15
5091
Regarding Tree View to Form View
action form view tree
Avatar
0
de març 15
4595
"Search More..." in many2one field Solved
view many2one search tree more
Avatar
Avatar
Avatar
Avatar
Avatar
4
de nov. 24
22083
Disable Create button in Tree view but keep Import
import treeview view tree button
Avatar
0
de jul. 25
11947
Can we add a button between the search view and the tree?
search tree button between object
Avatar
0
de març 15
4332
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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