2017-01-16 235 views
1

嗨,我有一個模式單位繼承product.product。 我已經定義了Unit的自定義視圖,它們在菜單中工作正常。如何更改odoo中的many2one字段的默認格式

繼承account.asset.assets的屬性具有多個單位。 如何從Property視圖調用我的自定義單位視圖? 當我點擊添加一個項目時,我會得到標準的產品表單。

<record id="unit_form" model="ir.ui.view"> 
     <field name="name">All Units</field> 
     <field name="model">product.product</field> 
     <field name="sequence">0</field> 
     <field name="arch" type="xml"> 
     <form string="Unit"> 

        <group> 
         <field name="property_id" widget="many2one" attrs="{'required': [('is_unit', '=', True)]}" /> 
         <field name="is_unit" invisible="1" /> 
         <field name="features_amenities_ids" placeholder="Features and Amenities" widget="many2many_tags" /> 
         <field name="appliences_ids" placeholder="Apliences" widget="many2many_tags" /> 
         <field name="lst_price" string="Rent" /> 
        </group> 

      </form> 
     </field> 
</record> 
<record id="unit_tree" model="ir.ui.view"> 
     <field name="name">All Units</field> 
     <field name="model">product.product</field> 
     <field name="arch" type="xml"> 
      <tree string="Units" default_order='property_id,name'> 

       <field name="property_id" /> 
       <field name="name" string="Unit#" /> 

      </tree> 
     </field> 
</record> 

<record id="action_unit" model="ir.actions.act_window"> 
     <field name="name">Units</field> 
     <field name="res_model">product.product</field> 
     <field name="view_mode">search, kanban,tree,form</field> 
     <field name="domain">[('is_unit', '=', True)]</field> 
     <field name="context">{'default_is_unit':1 }</field> 
     <field name="search_view_id" ref="unit_search"/> 
     <field name="help" type="html"> 
      <p class="oe_view_nocontent_create"> 
      Click to create a Unit. 
      </p> 
      <p> 
      Here you will find the all units. 
      </p> 
     </field> 
</record> 
<record id="action_unit_form" model="ir.actions.act_window.view"> 
     <field name="act_window_id" ref="action_unit" /> 
     <field name="view_id" ref="unit_form" /> 
     <field name="view_mode">form</field> 
     <field name="sequence">10</field> 
</record> 

<record id="action_unit_tree" model="ir.actions.act_window.view"> 
     <field name="act_window_id" ref="action_unit" /> 
     <field name="view_id" ref="unit_tree" /> 
     <field name="view_mode">tree</field> 
     <field name="sequence">9</field> 
</record> 

<record id="action_unit_kanban" model="ir.actions.act_window.view"> 
     <field name="act_window_id" ref="action_unit" /> 
     <field name="view_id" ref="product.product_kanban_view" /> 
     <field name="view_mode">kanban</field> 
     <field name="sequence">8</field> 
</record> 



<menuitem action="action_unit" sequence="2" 
     id="menu_units_list" name="Units" parent="menu_property_sub"/> 

這是來自地產

<notebook colspan="4"> 
    <page string="Units"> 
    <field name="unit_ids" nolabel="1" widget="one2many" > 
     <tree string="Units"> 
      <field name="name" string="Unit#"/> 
     </tree> 
    </field> 
    </page> 
</notebook> 

回答

1

如果要指定many2one或one2many領域的觀點:

<field name="m2o_id" context="{'form_view_ref': 'module_name.form_id'}"/> 

希望這會有所幫助。還有其他關鍵詞像樹視圖tree_view_ref

相關問題