2016-09-10 91 views

回答

1

要添加樹視圖按鈕嘗試下面的代碼:

<tree> 
    <button name="your_action" icon="rupee-symbol" 
        String="Payment" type="action" 
        attrs="{'invisible':[('status','!=','Confirmed')]}" /> 
</tree> 

希望它會幫助你..

0

創建一個文件夾嚮導

這將有

__init__.py 
file_name.py 
file_name_view.xml 


In Python file_name.py 

def fields_view_get(self, cr, uid, view_id=None, view_type='form', 
         context=None, toolbar=False, submenu=False): 
     if context is None: 
      context={} 
     res = super(class_name_wizard, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) 
     return res 

加入你的函數旁邊

在file_name_view.xml

<record model="ir.ui.view" id="new_id"> 
      <field name="name">New Wizard</field> 
      <field name="model">my.wizard</field> 
      <field name="arch" type="xml"> 
       <form string="New Form"> 
        <header> 
         <button name="do_generate" string="My Function" type="object"/> 
         or 
         <button string="Cancel" class ="oe_link" special="cancel"/> 
        </header> 
       </form> 
      </field> 
     </record> 

     <record id="action_my_function_wizard" model="ir.actions.act_window"> 
      <field name="name">My Function</field> 
      <field name="type">ir.actions.act_window</field> 
      <field name="res_model">my.wizard</field> 

      <field name="view_type">form</field> 
      <field name="view_mode">form</field> 
      <field name="target">new</field> 

     </record> 
     <act_window name="My Function" 
      res_model="my.wizard" 
      src_model="product.master" 
      view_mode="form" 
      target="new" 
      multi="True" 
      key2="client_action_multi" 
      id="action_view_my_new_id"/> 

注:src_model寫樹視圖的表名

希望這將幫助你

4

是,您可以像在窗體視圖中添加一樣在樹視圖中添加按鈕。

<tree string="My Tree"> 
    <button name="%{action_wiz_open}d" string="Scrap Products" type="action" icon="terp-gtk-jump-to-ltr" help="calls window action" /> 
    <button name="call_function" string="Process" type="object" help="calls python function" /> 
</tree> 

希望這有助於!

+2

這會在每一行中創建按鈕。如何在列表視圖的頁眉或頁腳創建按鈕? – ajay

相關問題