2016-12-06 4 views
0

Я использую Odoo 10.Odoo 10 - Javascript - ListView действие кнопки не работает

Я добавил кнопку к ListView.buttons, но я не могу связать действия с ним.

Моя кнопка:

<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

[РЕШИТЬ]

Я добавил 'контекст' и в 'Views' 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) 
    } 
})