2017-06-17 72 views
0

我正在嘗試爲自定義模塊定義一個設置視圖。設置視圖中的重複保存和取消按鈕

我按照雙方的官方文檔和博客,幫助你的代碼適應Odoo 10:

http://odoo-development.readthedocs.io/en/latest/dev/py/res.config.settings.html http://ludwiktrammer.github.io/odoo/custom-settings-odoo.html

目前,這是我的代碼顯示形式:

<record id="mymodule_configuration_form" model="ir.ui.view"> 
     <field name="name">TEST Settings</field> 
     <field name="model">mymodule_settings</field> 
     <field name="arch" type="xml"> 
      <form class="oe_form_configuration"> 
       <header> 
        <button string="Save" type="object" 
         name="execute" class="oe_highlight"/> 
        <button string="Cancel" type="object" 
         name="cancel" class="oe_link"/> 
       </header> 
       <sheet> 
        <group> 
         <label for="color"/> 
         <field name="color"/> 
        </group> 
       </sheet> 
      </form> 
     </field> 
    </record> 

這是菜單的代碼:

<menuitem id="mymodule_menu" 
       name="Custom Saleorder" 
       parent="base.menu_custom" /> 

    <act_window id="mymodule_settings_action" 
       name="Custom Saleorder Settings Action" 
       res_model="mymodule_settings" 
       view_mode="form" /> 
    <menuitem id="mymodule_settings_menu" 
       name="Settings" 
       action="mymodule_settings_action" 
       parent="mymodule_menu" /> 

雖然這樣做,我發現我已經複製按鈕,我如何刪除上述的?

enter image description here

我認爲,我對付它繼承res.config.settings模型中的事實是相關的。

+0

你不需要添加保存和取消按鈕。 Odoo將追加本身。只需從標題部分刪除這些按鈕即可。然後再試一次。 – KbiR

+0

我是這樣做的,但Odoo默認添加的按鈕不會保存/更新ir_config_param表。 –

回答

0

刪除您添加的按鈕,這些按鈕會自動創建並由Odoo顯示(取決於用戶的權限)。

當您單擊保存,與set_開始調用任何方法,所以做創建一個名爲def set_settings例如方法和方法將被自動調用該方法(假設你的設置模式從res.config.settings繼承)保存您的設置。

看看odoo/addons/base/res/res_config.py的文檔字符串