xmltreeviewodooodoo-8openerp-8

multiple tree views for same model odoo version 8


i have a problem ! well I've been trying to inherit the model product.template and create a new menu-item and action window in order to call a new independent tree view
but my new tree view is affecting the old one ! here's my code !

<?xml version="1.0"?>
<openerp>
 <data>
  <record id="new_view_tree_modif_product" model="ir.ui.view">
    <field name="name">new_view_tree_modif_product</field>
    <field name="model">product.template</field>
    <field name="arch" type="xml">
      <tree editable="bottom" create="0" colors="red:inf_marge_min==True">
          <field name="name" string="Nom" readonly="1"/>
          <field name="standard_price" string="Prix de revient" readonly="1"/>
          <field name="marge" string="Marge"/>
          <field name="list_price" string="Prix de vente"/>
          <field name="inf_marge_min" invisible="1"/>
        </tree>
    </field>
  </record>
  <act_window id="action_new_view_product"
              name="Etude de prix"
              res_model="product.template"
              view_mode="tree" />
  <menuitem id="menu_prix_modif_product"
            name="Prix"
            parent="base.menu_product"
            sequence="9"
            action="action_new_view_product" />
  <record id="tree_id" model="ir.actions.act_window.view">
    <field eval="3" name="sequence"/>
    <field name="view_mode">tree</field>
    <field name="view_id" ref="new_view_tree_modif_product"/>
    <field name="act_window_id" ref="action_new_view_product"/>
  </record>
</data>

well its affecting the default tree view how can i call my tree view without affecting old one thnx


Solution

  • well in order to achieve this , i had to create a main action wich regroup two actions for the new views :

    <record id="action_1" model="ir.actions.act_window">
       <field name="name">new view</field>                                         
       <field name="res_model">model.name</field>                                  
       <field name="view_type">form</field>                                        
       <field name="view_mode">tree,form</field>                                   
       <field eval="False" name="view_id"/>                                        
    </record>
    

    so this is the main action , now we should create actions for each view: action 1 for our new tree view

    <record id="action_new_tree" model="ir.actions.act_window.view">     
        <field eval="1" name="sequence"/>  
        <field name="view_mode">tree</field>  
        <field name="view_id" ref="external id of your new tree view"/>
        <field name="act_window_id" ref="action_1"/>
    </record>
    

    now we made an action for our new tree view , and link it the first action ,we should do the same for the form

    <record id="action_new_form" model="ir.actions.act_window.view">     
        <field eval="1" name="sequence"/>  
        <field name="view_mode">form</field>  
        <field name="view_id" ref="external id of your new form view"/>
        <field name="act_window_id" ref="action_1"/>
    </record>
    

    perfect , all we need now is to create a menuitem for the first action (action1)

    <menuitem id="id_of_ur_new_menu"  
     name="new form and tree view for an existing model"               
     parent="parent.menu "               
     action="action_1"/>