2016-12-06 41 views
0

を動作していないが、私はそれにアクションをリンクすることはできません。Odoo 10 - Javascriptを - リストビューボタンアクションは、私が<em>ListView.buttons</em>にボタンを追加しました</p> <p>Odoo 10を使用しています

マイボタン:

<t t-extend="ListView.buttons"> 
    <t t-jquery="button.o_list_button_add" t-operation="after"> 
     <t t-if="widget.fields_view.name == 'site.tree'"> 
      <button type="button" class="btn btn-primary btn-sm oe_create_customer_button"> 
       Create Customer Site 
      </button> 
     </t> 
    </t> 
</t> 

JSコード:

openerp.broadband = function(instance, local) { 

instance.web.ListView.include({ 
    render_buttons: function() { 
     this._super.apply(this, arguments) 
     if (this.$buttons) { 
      this.$buttons.find('.oe_create_customer_button').on('click', this.proxy('do_new_button')) 
     } 
    }, 
    do_new_button: function() { 
     this.do_action({ 
      type: 'ir.actions.act_window', 
      name: 'site_wizard_act_js', 
      res_model: 'broadband.wizard', 
      view_type: 'form', 
      view_mode: 'form', 
      view_id: 'site_wizard_act', 
      target: 'new', 
     }) 
    } 
}) 
} 

しかしOdooは私に'例外TypeError:this.view_order [0]は未定義である' 与え、私はボタンをクリックしたときを。

誰かが私を助けることができますか?

ありがとうございました。 【解決しよう】

答えて

0

Iは、'文脈'とアクションで'ビュー'のparamsを加えました。

instance.web.ListView.include({ 
    render_buttons: function() { 
     this._super.apply(this, arguments) 
     if (this.$buttons) { 
      this.$buttons.find('.oe_create_customer_button').on('click', this.proxy('do_new_button')) 
     } 
    }, 
    do_new_button: function() { 
     var context = { 
      'id': this.id, 
     } 
     var action = ({ 
      type: 'ir.actions.act_window', 
      res_model: 'broadband.wizard', 
      view_type: 'form', 
      view_mode: 'form', 
      views: [[false, 'form']], 
      target: 'new', 
      context: context 
     }) 
     this.do_action(action) 
    } 
}) 
関連する問題