2016-04-26 13 views
0

で新しいインポートボタンを作成し、私は2つのクラスがあります。私のPythonコードでodoo

class object_one(osv.osv): 
    _name = "object.one" 

class object_two(osv.osv): 
    _name = "object.two" 

を私はobject.oneのフォームビューでカスタマイズのインポート]ボタンを作成したいです私はのbase_importモジュールのファイルを検索しようとしましたが、元のインポートボタンがどこから(どのXMLファイル)作成されたか知っていれば役に立ちます。

enter image description here

答えて

1

Here is the code for xml

<t t-extend="ListView.buttons"> 
    <t t-if='widget.options.import_enabled' t-jquery="button.o_list_button_add" t-operation="after"> 
     <button type="button" class="btn btn-sm btn-default o_list_button_import"> 
      Import 
     </button> 
    </t> 
</t> 
here is code for js

if(add_button) { 
     this.$buttons.on('click', '.o_list_button_import', function() { 
      self.do_action({ 
       type: 'ir.actions.client', 
       tag: 'import', 
       params: { 
        model: self.dataset.model, 
        // self.dataset.get_context() could be a compound? 
        // not sure. action's context should be evaluated 
        // so safer bet. Odd that timezone & al in it 
        // though 
        context: self.getParent().action.context, 
       } 
      }, { 
       on_reverse_breadcrumb: function() { 
        return self.reload(); 
       }, 
      }); 
      return false; 
     }); 
    } 

基本的ImportViewは、データをインポートするためODOOに使用ウィジェットです。方法onfile_loaded

Controller /base_import/set_fileを呼び出すodoo:

onfile_loaded: function() { 
    this.$buttons.filter('.o_import_button').add(this.$('.oe_import_file_reload')) 
      .prop('disabled', true); 
    if (!this.$('input.oe_import_file').val()) { return; } 

    this.$el.removeClass('oe_import_preview oe_import_error'); 
    this.$el.find('.oe_import_toggle').toggle((this.$('input.oe_import_file')[0].files[0].type == "text/csv")); 
    jsonp(this.$el, { 
     url: '/base_import/set_file' 
    }, this.proxy('settings_changed')); 
}, 

が、これは輸入の作業を変更/理解に役立つことを願っています。

関連する問題