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,odoo撥打Controller /base_import/set_file:/
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'));
},
希望這可以幫助你理解改變進口工作。