I have two classes:
class first_class(models.Model):
_name = 'tbl1'
code = fields.Char('Code', size=3, required=True)
description = fields.Char('Description', size=40, required=True)
class second_class(models.Model):
_name = 'tbl2'
_inherits = {'tbl1': 'id_tbl1'}
id_tbl1 = fields.Many2one('tbl1')
employee = fields.Char('Name', size=40, required=True)
When I create a new row with the first class, I would like to go directoly to the second class with the id I've just created. That is I would like to pass the id of tbl1 to tbl2.
Is it possible?
This is my XML file:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_mymodule_tbl1_tree" model="ir.ui.view">
<field name="name">mymodule.tbl1.tree.view</field>
<field name="model">tbl1</field>
<field name="arch" type="xml">
<tree string="Bridge" export="false">
<field name="id"/>
<field name="code"/>
<field name="description"/>
</tree>
</field>
</record>
<record id="view_mymodule_tbl1_form" model="ir.ui.view">
<field name="name">mymodule.tbl1.form.view</field>
<field name="model">tbl1</field>
<field name="arch" type="xml">
<form string="Bridge" duplicate="false">
<header>
<button name="%(action_mymodule_tbl2)d" type="action" string="Submit" />
</header>
<sheet>
<group>
<field name="code"/>
<field name="description"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_mymodule_tbl1" model="ir.actions.act_window">
<field name="name">action tbl1</field>
<field name="res_model">tbl1</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" eval="False"/>
</record>
<menuitem action="action_mymodule_tbl1" id="menu_action_mymodule_tbl1" parent="mail.mail_feeds" sequence="140"/>
<record id="view_mymodule_tbl2_tree" model="ir.ui.view">
<field name="name">mymodule.tbl2.tree.view</field>
<field name="model">tbl2</field>
<field name="arch" type="xml">
<tree string="Mymodule" export="false">
<field name="id_tbl1" readonly="1"/>
<field name="employee
</tree>
</field>
</record>
<record id="view_mymodule_tbl2_form" model="ir.ui.view">
<field name="name">mymodule.tbl2.form.view</field>
<field name="model">tbl2</field>
<field name="arch" type="xml">
<form string="Mymodule" duplicate="false">
<group>
<field name="id_tbl1" readonly="1"/>
<field name="employee"/>
</group>
</form>
</field>
</record>
<record id="action_mymodule_tbl2" model="ir.actions.act_window">
<field name="name">Insert</field>
<field name="res_model">tbl2</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_mymodule_tbl2_form" />
<field name="target">new</field>
</record>
<menuitem action="action_mymodule_tbl2" id="menu_action_mymodule_tbl2" parent="mail.mail_feeds" sequence="150"/>
</data>
</openerp>