2012-04-04 47 views

回答

6

以下是顯示如何在OpenERP中開發看板視圖的示例代碼。

對於看板視圖,您必須準備2個文件:(1)xml文件和(2)css文件。 CSS文件用於看板視圖的格式化。

<record model="ir.ui.view" id="resource_kanban_view"> 
    <field name="name">any name of ur model</field> 
    <field name="model">object.name</field> 
    <field name="type">kanban</field> 
    <field name="arch" type="xml"> 
     <kanban> 
      <templates> 
       <t t-name="kanban-box"> 
        <div class="oe_resource_vignette"> 
         <div class="oe_resource_image"> 
          <a type="edit"><img t-att-src="kanban_image('object.name', 'photo', record.id.value)" class="oe_resource_picture"/></a> 
         </div> 
         <div class="oe_resource_details"> 
          <ul> 
<!--Here you have to write the object's field name which you want to display in kanban view --> 
           <li><field name="name"/></li> 
           <li><field name="author"/></li> 
           <li><field name="description"/></li> 
           <li><field name="available_copy"/> </li>         
          </ul> 
         </div> 
        </div>      
       </t> 
      </templates> 
     </kanban> 
    </field> 
</record> 
1

我看不到它的任何文檔,所以最好的辦法是在插件項目中查找示例。搜索所有的XML文件<kanban>。下面是來自stock module一個例子:

<record model="ir.ui.view" id="product.product_kanban_view"> 
     <field name="name">Product Kanban</field> 
     <field name="model">product.product</field> 
     <field name="type">kanban</field> 
     <field name="arch" type="xml"> 
      <kanban> 
       <field name="color"/> 
       <field name="type"/> 
       <field name="product_image"/> 
       <field name="list_price"/> 
       <templates> 
        <t t-name="kanban-box"> 
         <div class="oe_product_vignette"> 
          <div class="oe_product_img"> 
          <a type="edit"><img t-att-src="kanban_image('product.product', 'product_image', record.id.value)" class="oe_product_photo"/></a> 
          </div> 
          <div class="oe_product_desc"> 
           <h4><a type="edit"><field name="name"></field></a></h4> 
           <ul> 
            <li t-if="record.type.raw_value != 'service'">Stock on hand: <field name="qty_available"/> <field name="uom_id"/></li> 
            <li t-if="record.type.raw_value != 'service'">Stock available: <field name="virtual_available"/> <field name="uom_id"/></li> 
            <li>Price: <field name="lst_price"></field></li> 
            <li>Cost: <field name="standard_price"></field></li> 
           </ul> 
          </div> 
         </div> 
         <script> 
          $('.oe_product_photo').load(function() { if($(this).width() > $(this).height()) { $(this).addClass('oe_product_photo_wide') } }); 
         </script> 
         <div></div> 
        </t> 
       </templates> 
      </kanban> 
     </field> 
    </record> 
2

他們是文檔此,看板觀點是基於QWEB技術創建的,通過自身的發展,可以看到整個的lib QWEB lib,並在文件節中,你可以看到您可以定義qWeb QWEB Template,現在,如果你瞭解它,然後你只需要做的就是出在視圖聲明,而其他精業公司是一樣的通用視圖聲明標記下您的網頁模板:

<record model="ir.ui.view" id="view_external_id"> 
     <field name="name">View Name</field> 
     <field name="model">openerp.modelfield> 
     <field name="type">kanban</field> 
     <field name="arch" type="xml"> 
      <kanban> 
       <field name="color"/> 
       <!--list of field to be loaded --> 
       <field name="list_price"/> 
       <templates> 
        <!--Your Qweb based template goes here, each record will be wrapped in template so you can arrange field veyr easily in box --> 
       </templates> 
      </kanban> 
     </field> 
    </record> 

希望這將幫你。

問候

-2

只需在XML文件更新這個模型=「ir.actions.act_window」與view_mode像:

 <record id="action_id" model="ir.actions.act_window"> 
     <field name="name">Name1</field> 
     <field name="type">ir.actions.act_window</field> 
     <field name="res_model">model_name</field> 
     <field name="view_type">form</field> 
     <field name="view_mode">kanban,tree,form,calendar,graph,gantt</field> 
..... 
</record> 

這是怎樣的方式調用所有視圖,並鏈接http://www.slideshare.net/openobject/openerp-61-framework-changes幫助你如何創建看板視圖。我希望它能幫助你...

相關問題