2017-02-09 6 views
-1

このボタンをツリービューに追加するには?私
ライブラリ/静的/ SRC/JS/script.js
odooツリービューの作成ボタンの次にボタンを追加

openerp.library = function(instance) { 

    instance.web.ListView.include({ 
     load_list: function(data) { 
      this._super(data); 
      if (this.$buttons) { 
       this.$buttons.find('.oe_my_button').off().click(this.proxy('do_the_job')); 
      } 
     }, 
     do_the_job: function() { 

      this.do_action({ 
       name: _t("View name"), 
       type: "ir.actions.act_window", 
       res_model: "object", 
       domain: [], 
       views: [ 
        [false, "list"], 
        [false, "tree"] 
       ], 
       target: 'new', 
       context: {}, 
       view_type: 'list', 
       view_mode: 'list' 
      }); 
     } 
    }); 
} 

で このコードこのコードは、ライブラリ内の/静的/ SRC/XML/library_view.xml

<template xml:space="preserve"> 
    <t t-extend="ListView.buttons"> 
     <t t-jquery="button.oe_list_add" t-operation="after"> 
      <button t-if="widget.dataset.model == 'inventory'" class="oe_button oe_my_button oe_highlight" type="button">My Button</button> 
     </t> 
    </t> 
</template> 

openerp .py

'qweb': ['static/src/xml/library_view.xml'], 
+0

問題は何ですか?インスペクタのコンソールに何かエラーがありますか?あなたのJSがロードされていることを確認していますか? – simahawk

答えて

0

ライブラリ/ statはどうなりますかic/src/js/script.jsファイル?以下のようなodooバックエンド資産テンプレートの

追加JSファイル: -

<template id="assets_backend" name="work_group assets" inherit_id="web.assets_backend"> 
    <xpath expr="." position="inside"> 
     <script 
      type="text/javascript" 
      src="/library/static/src/js/script.js"> 
     </script> 

    </xpath> 
</template> 
関連する問題