2017-04-22 75 views
1

您好,我已經在Odoo 10表單上創建了一個按鈕「SET geprint」,現在我想將一個動作附加到按鈕上。如果我按下按鈕,布爾geprint的值必須變爲1.我怎樣才能使這成爲可能?我該如何製作和執行按鈕的動作

如果可能我還想在列表視圖中創建該按鈕來更新多個記錄。 THX的幫助

enter image description here

我想你的代碼,但現在我收到以下錯誤 (name字段更新是x_geprint) 按鈕代碼:

enter image description here enter image description here

回答

0

做一個服務器動作(設置 - >技術 - >服務器操作) Save the action if you want you can add the action to the action menu

在您的鏈接,搜索動作號碼後請參閱圖像(我的電話號碼是638) enter image description here

然後轉到要添加按鈕的表單。在我的例子中它的股票。移動

進入編輯FormView控件,並添加以下代碼

<button name="638" string=" Set geprint" type="action" /> 
0

您可以通過執行以下方法

  1. 創建對象類型的按鈕在窗體視圖中。你可以給按鈕type =「object」,之後當你點擊按鈕的時候系統會調用python方法你可以在其中編寫代碼。

例如:

<button name="validate" string="Validate" type="object" states="draft" class="oe_highlight"/> 

@api.multi 
def validate(self): 
    self.write({}) 
    return True 
  • 對於需要創建新的嚮導的列表視圖中,可以在其中從列表視圖記錄選擇數並在列表視圖動作選擇您的嚮導名稱項目
  • 例:

    from openerp import models, fields, api, _ 
    
    class test(models.TransientModel): 
        _name = 'test.test' 
    
    
    <act_window name="Name String" res_model="wizard.model" 
        src_model="source.model" view_mode="form" view_type="form" 
        target="new" multi="False" 
        id="your_id" 
        view_id="view_id"   
        context="{}"/> 
    

    源模型操作菜單您可以選擇嚮導鏈接並在嚮導你會在上下文中得到active_ids。

    active_ids表示所有列表視圖選定的記錄,基於此,您可以使用選擇性記錄進行任何操作。

    這可能對你有幫助。