Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to trigger action depending on selection value ?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
actionformviewselectionodoo9
2 Risposte
7742 Visualizzazioni
Avatar
Azzedine

Hello everyone,

suppose i have my model_main, model_1 and model_2 with their correponding view_main, view_1 and view_2. I have a selection field in my model_main and i want to display a form (trigger action_1 or action_2) depending on my selection value, how can i do that  ?

 

0
Avatar
Abbandona
Avatar
Azzedine
Autore Risposta migliore

@Juan Thank you for your answer, but it doesn't work. Here is my try :

py file :

class T_Component(models.Model):
_name = 't.component'
wtg_id = fields.One2many('t.wtg','component_id')
other_id = fields.One2many('t.other','component_id')
t_substation_id = fields.Many2one('t.substation','Substation')
component_type = fields.Selection(string="Type du composant",selection=[('wtg','Turbine'),('nop','Not implemented')])
#@api.onchange('component_type')
def onchange_type(self) :
if self.component_type :
if self.component_type == "Turbine" :
return {
'type': 'ir.actions.act_window',
'name': 'Turbine',
'view_type': 'form',
'view_mode': 'form',
'view_id': 'view_wtg_form',
'res_model': 't.wtg',
'nodestroy': True,
'target': 'current',
'res_id': self.component_type,
}
if self.component_type == "Not implemented" :
return {
'type': 'ir.actions.act_window',
'name': 'Autre',
'view_type': 'form',
'view_mode': 'form',
'view_id': 'view_other_form',
'res_model': 't.other',
'nodestroy': True,
'target': 'current',
'res_id':self.component_type,
}


xml file :

<?xml version="1.0" encoding ="utf-8"?>
<openerp>
<data>
<!-- FORM -->
<record id="view_component_form" model="ir.ui.view">
<field name="model">t.component</field>
<field name="name">t.component.form.view</field>
<field name="arch" type="xml">
<form string="Fiche Composants" version="7.0">
<sheet>
<group string="Informations generales">
<field name="t_substation_id" options="{'no_create_edit': True}"/>
<field name="component_type"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="view_wtg_form" model="ir.ui.view">
<field name="model">t.wtg</field>
<field name="name">t.wtg.form.view</field>
<field name="arch" type="xml">
<form string="Turbine form" version="7.0">
<sheet>
<group string="Turbines and turbiners informations">
<field name="rec_turbine"/>
<field name="itt_nserie"/>
<field name="iwp_invt_wp"/>
<field name="itt_type_turbine"/>
<field name="itt_dim_rotor"/>
<field name="itt_haut_mat"/>
<field name="itt_lat_turbine"/>
<field name="itt_lon_turbine"/>
<field name="itt_proc_givre"/>
<field name="itt_brid_perm"/>
<field name="iat_marque_cel"/>
<field name="hse_sys_anti_intr"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="view_other_form" model="ir.ui.view">
<field name="model">t.other</field>
<field name="name">t.other.form.view</field>
<field name="arch" type="xml">
<form string="Other form" version="7.0">
<sheet>
<group string="Component Informations">
<field name="component_id"/>
<field name = "value" />
</group>
</sheet>
</form>
</field>
</record>

I've also tried to compare with the value in self.component_id but it doesn't work neither, Did I miss something ?

0
Avatar
Abbandona
Avatar
Juan Vicente Pascual
Risposta migliore

Hello,

Create a function in model_main  onchange_selection_field (see examples searching for onchange in odoo code)

then make if statement of selected value and show form like,

return {

'type': 'ir.actions.act_window',

'name': 'your_form_name',

'view_type': 'form',

'view_mode': 'form',

'view_id': <-- the id of the view,

'res_model': 'your model',

'nodestroy': True,

'target': 'current',

'res_id': <-- ids of values selected or False,

}


Kind Regards,

Juanvi

0
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Open form in view mode? Risolto
action xml form view
Avatar
Avatar
Avatar
Avatar
Avatar
4
dic 21
33375
Regarding Tree View to Form View
action form view tree
Avatar
0
mar 15
4586
How to give the action call in form a specific product.id?
action xml form template odoo9
Avatar
0
apr 17
3481
How to set inline view only in form?
action form view inline odoo8.0
Avatar
0
lug 16
6635
how to trigger an action onLoad of a form view?
action trigger form view onload
Avatar
Avatar
Avatar
2
ott 15
18592
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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