Skip to Content
Menu
This question has been flagged
3 Replies
5788 Views

I have created a simple module. This is the view:

 <?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_test_1" model="ir.ui.view">
<field name="name">Test 1</field>
<field name="model">test.tbl_1</field>
<field name="arch" type="xml">
<form string="Test 1">
<sheet>
<group name="top">
<group name="left">
<field name="code_1"/>
</group>
<group name="left">
<field name="description_1"/>
</group>
</group>
</sheet>
</form>
</field>
</record>

<record id="view_test_2" model="ir.ui.view">
<field name="name">Test 2</field>
<field name="model">test.tbl_2</field>
<field name="arch" type="xml">
<form string="Test 2">
<sheet>
<group name="top">
<group name="left">
<field name="code_2"/>
</group>
<group name="left">
<field name="description_2"/>
</group>
</group>
</sheet>
</form>
</field>
</record>

<!-- Action to open To-do Task list -->
<act_window id="action_test_1" name="Attivita" res_model="test.table_1" view_mode="tree,form" />
<act_window id="action_test_2" name="Servizio" res_model="test.table_2" view_mode="tree,form" />
<!-- Menu item to open To-do Task list -->
<menuitem id="menu_test_1" name="Menu test 1" parent="mail.mail_feeds" sequence="20" action="action_test_1" />
<menuitem id="menu_test_2" name="Menu test 2" parent="mail.mail_feeds" sequence="30" action="action_test_2" />

</data>
</openerp>

and this is my model:

# -*- encoding: utf-8 -*-
from openerp import models, fields

class test_1(models.Model):
_name = 'test.table_1'
_description = 'Table 1'

code_1 = fields.Char('Code', size=1, help="Insert your code", required=True)
description_1 = fields.Text('Description', help="Insert a description", required=True)

class test_2(models.Model):
_name = 'test.table_2'
_description = 'Table 2'

code_2 = fields.Char('Code', size=1, help="Insert your code", required=True)
description_2 = fields.Text('Description', help="Insert a description", required=True)

So, I have two links in the "messaging" menu, one for each action.

Instead, I need only one link to a view with two forms. I would like to chose which one to fill (only one or both).

Anyone coul help me? Thanks in advance!

Avatar
Discard

In your view, there are tags mismatch (group and sheet).

Author Best Answer

Thank your for your reply, Tarek.

I thought to something like this: one views with two tabs (one for each form).

Any suggestion?

PY, the tags 'group' and 'sheet' are not mismatched. They are not correctly indented.

Avatar
Discard
Best Answer

I suggest the following scenario:

You have to create a wizard screen that has a popup to select one of the two views.

Create a link to open this wizard, and in the 'OK' button of the wizard you have to return an action that calls the selected view.

In this case no need for the created two actions above.

search the odoo code to get how to build an action programmatically, use the key word:

'type': 'ir.actions.act_window'

Avatar
Discard