2016-12-06 2 views
0

을 작동하지 않는,하지만 난 그것에 조치를 링크 할 수 없습니다.Odoo 10 - 자바 스크립트 - ListView에 버튼 액션은 내가이 <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 나에게 '형식 오류 : this.view_order [0] 정의되지 않은'제공 I 버튼을 클릭하면합니다.

나를 도와 줄 사람이 있습니까?

감사합니다.

[이 해결]

답변

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) 
    } 
})