@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 ?