2011-07-07 10:01:04 +00:00
|
|
|
openerp.base_export = function(openerp) {
|
|
|
|
QWeb.add_template('/base_export/static/src/xml/base_export.xml');
|
|
|
|
openerp.base.views.add('export', 'openerp.base_export.Export');
|
2011-07-13 07:16:41 +00:00
|
|
|
openerp.base_export.Export = openerp.base.Dialog.extend({
|
2011-07-07 10:01:04 +00:00
|
|
|
|
2011-07-19 12:32:09 +00:00
|
|
|
init: function(parent, dataset, views){
|
2011-07-19 06:30:41 +00:00
|
|
|
this._super(parent);
|
2011-07-07 10:01:04 +00:00
|
|
|
this.dataset = dataset
|
2011-07-19 12:32:09 +00:00
|
|
|
this.views = views
|
|
|
|
this.views_id = {};
|
|
|
|
for (var key in this.views) {
|
|
|
|
this.views_id[key] = this.views[key].view_id
|
|
|
|
}
|
2011-07-07 10:01:04 +00:00
|
|
|
},
|
2011-07-12 10:21:18 +00:00
|
|
|
|
2011-07-07 10:01:04 +00:00
|
|
|
start: function() {
|
2011-07-13 09:02:18 +00:00
|
|
|
var self = this
|
|
|
|
self._super(false);
|
|
|
|
self.template = 'ExportTreeView';
|
|
|
|
self.dialog_title = "Export Data "
|
|
|
|
self.open({
|
|
|
|
modal: true,
|
2011-07-21 09:11:02 +00:00
|
|
|
width: '55%',
|
2011-07-13 09:02:18 +00:00
|
|
|
height: 'auto',
|
|
|
|
position: 'top',
|
|
|
|
buttons : {
|
2011-07-11 11:45:37 +00:00
|
|
|
"Close" : function() {
|
2011-07-13 07:16:41 +00:00
|
|
|
self.close();
|
2011-07-11 11:45:37 +00:00
|
|
|
},
|
|
|
|
"Export To File" : function() {
|
2011-07-18 12:49:40 +00:00
|
|
|
self.on_click_export_data();
|
2011-07-11 11:45:37 +00:00
|
|
|
}
|
2011-07-13 05:26:02 +00:00
|
|
|
},
|
2011-07-13 09:02:18 +00:00
|
|
|
close: function(event, ui){ self.close();}
|
|
|
|
});
|
2011-07-15 10:23:14 +00:00
|
|
|
this.on_show_exists_export_list();
|
2011-07-21 05:12:32 +00:00
|
|
|
jQuery(this.$dialog).removeClass('ui-dialog-content ui-widget-content');
|
2011-07-14 06:13:52 +00:00
|
|
|
$('#add_field').click(function(){
|
2011-07-21 08:44:20 +00:00
|
|
|
if($("#field-tree-structure tr.ui-selected")){
|
|
|
|
var fld = $("#field-tree-structure tr.ui-selected").find('a');
|
|
|
|
for (var i=0;i<fld.length; i++){
|
|
|
|
var id = $(fld[i]).attr('id').split("-")[1];
|
|
|
|
var string = $(fld[i]).attr('string');
|
|
|
|
self.add_field(id,string);
|
|
|
|
}
|
|
|
|
$("#field-tree-structure tr").removeClass("ui-selected");
|
2011-07-14 06:13:52 +00:00
|
|
|
}
|
2011-07-12 10:21:18 +00:00
|
|
|
});
|
2011-07-14 06:13:52 +00:00
|
|
|
$('#remove_field').click(function(){
|
2011-07-14 13:20:11 +00:00
|
|
|
$("#fields_list option:selected").remove();
|
2011-07-13 06:06:46 +00:00
|
|
|
});
|
2011-07-14 06:13:52 +00:00
|
|
|
$('#remove_all_field').click(function(){
|
2011-07-14 13:20:11 +00:00
|
|
|
$("#fields_list option").remove();
|
2011-07-13 06:06:46 +00:00
|
|
|
});
|
2011-07-14 11:41:43 +00:00
|
|
|
$('#export_new_list').click(function(){
|
|
|
|
self.on_show_save_list();
|
|
|
|
});
|
2011-07-19 12:32:09 +00:00
|
|
|
import_comp = $("#import_compat option:selected").val()
|
2011-07-19 13:04:23 +00:00
|
|
|
var params = {"import_compat":parseInt(import_comp), "views_id": this.views_id}
|
|
|
|
this.rpc("/base_export/export/get_fields", {"model": this.dataset.model, "params": params}, this.on_show_data);
|
2011-07-21 05:12:32 +00:00
|
|
|
|
2011-07-19 12:32:09 +00:00
|
|
|
$("#import_compat").change(function(){
|
2011-07-21 08:44:20 +00:00
|
|
|
$("#fields_list option").remove();
|
|
|
|
$("#field-tree-structure").remove();
|
|
|
|
import_comp = $("#import_compat option:selected").val();
|
|
|
|
if(import_comp){
|
|
|
|
var params = {"import_compat":parseInt(import_comp), "views_id": this.views_id}
|
|
|
|
self.rpc("/base_export/export/get_fields", {"model": self.dataset.model, "params": params}, self.on_show_data);
|
|
|
|
}
|
|
|
|
});
|
2011-07-15 10:23:14 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
on_show_exists_export_list: function(){
|
|
|
|
var self = this;
|
|
|
|
if($("#saved_export_list").is(":hidden")){
|
|
|
|
$("#ExistsExportList").show();
|
|
|
|
}
|
|
|
|
else{
|
2011-07-15 12:22:01 +00:00
|
|
|
this.rpc("/base_export/export/exist_export_lists", {"model": this.dataset.model}, function(export_list){
|
|
|
|
if(export_list.length){
|
|
|
|
$("#ExistsExportList").append(QWeb.render('Exists.ExportList', {'existing_exports':export_list}));
|
|
|
|
$("#saved_export_list").change(function(){
|
|
|
|
$("#fields_list option").remove();
|
|
|
|
export_id = $("#saved_export_list option:selected").val();
|
|
|
|
if (export_id){
|
|
|
|
self.rpc("/base_export/export/namelist", {"model": self.dataset.model, export_id: parseInt(export_id)}, self.do_load_export_field);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#delete_export_list').click(function(){
|
|
|
|
select_exp = $("#saved_export_list option:selected")
|
|
|
|
if (select_exp.val()){
|
|
|
|
self.rpc("/base_export/export/delete_export", {"export_id": parseInt(select_exp.val())}, {});
|
|
|
|
select_exp.remove();
|
|
|
|
if($("#saved_export_list option").length <= 1){
|
2011-07-15 10:23:14 +00:00
|
|
|
$("#ExistsExportList").hide();
|
2011-07-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
do_load_export_field: function(field_list){
|
|
|
|
var export_node = $("#fields_list");
|
|
|
|
for (var key in field_list) {
|
|
|
|
export_node.append(new Option(field_list[key], key));
|
2011-07-15 10:23:14 +00:00
|
|
|
}
|
2011-07-11 05:03:35 +00:00
|
|
|
},
|
2011-07-15 10:23:14 +00:00
|
|
|
|
2011-07-14 11:41:43 +00:00
|
|
|
on_show_save_list: function(){
|
|
|
|
var self = this;
|
|
|
|
var current_node = $("#savenewlist");
|
|
|
|
if(!(current_node.find("label")).length){
|
|
|
|
current_node.append(QWeb.render('ExportNewList'));
|
|
|
|
current_node.find("#add_export_list").click(function(){
|
|
|
|
var value = current_node.find("#savelist_name").val();
|
|
|
|
if (value){
|
|
|
|
self.do_save_export_list(value);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
alert("Pleae Enter Save Field List Name");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if (current_node.is(':hidden')){
|
|
|
|
current_node.show();
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
current_node.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
do_save_export_list: function(value){
|
2011-07-15 10:23:14 +00:00
|
|
|
var self = this;
|
|
|
|
var export_field = self.get_fields()
|
2011-07-14 11:41:43 +00:00
|
|
|
if(export_field.length){
|
2011-07-15 10:23:14 +00:00
|
|
|
self.rpc("/base_export/export/save_export_lists", {"model": self.dataset.model, "name":value, "field_list":export_field}, function(exp_id){
|
|
|
|
if(exp_id){
|
|
|
|
if($("#saved_export_list").length > 0){
|
|
|
|
$("#saved_export_list").append( new Option(value, exp_id));
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
self.on_show_exists_export_list();
|
|
|
|
}
|
|
|
|
if($("#saved_export_list").is(":hidden")){
|
|
|
|
self.on_show_exists_export_list();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
self.on_show_save_list()
|
2011-07-14 13:20:11 +00:00
|
|
|
$("#fields_list option").remove();
|
2011-07-14 11:41:43 +00:00
|
|
|
}
|
|
|
|
},
|
2011-07-11 05:03:35 +00:00
|
|
|
|
|
|
|
on_click: function(id, result) {
|
|
|
|
var self = this
|
2011-07-14 06:13:52 +00:00
|
|
|
self.field_id = id.split("-")[1];
|
|
|
|
var model = ''
|
|
|
|
var prefix = ''
|
|
|
|
var name = ''
|
|
|
|
var is_loaded = 0;
|
2011-07-13 09:02:18 +00:00
|
|
|
_.each(result, function(record) {
|
2011-07-14 06:13:52 +00:00
|
|
|
if(record['id'] == self.field_id && (record['children']).length >= 1){
|
2011-07-13 09:02:18 +00:00
|
|
|
model = record['params']['model']
|
|
|
|
prefix = record['params']['prefix']
|
|
|
|
name = record['params']['name']
|
2011-07-14 06:13:52 +00:00
|
|
|
$(record['children']).each (function(e, childid) {
|
2011-07-14 07:09:45 +00:00
|
|
|
if ($("tr[id='treerow-" + childid +"']").length > 0) {
|
|
|
|
if ($("tr[id='treerow-" + childid +"']").is(':hidden')) {
|
2011-07-14 06:13:52 +00:00
|
|
|
is_loaded = -1;
|
|
|
|
} else {
|
|
|
|
is_loaded++;
|
2011-07-13 09:02:18 +00:00
|
|
|
}
|
2011-07-14 06:13:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (is_loaded == 0) {
|
2011-07-21 05:12:32 +00:00
|
|
|
if ($("tr[id='treerow-" + self.field_id +"']").find('img').attr('src') == '/base_export/static/src/img/expand.gif') {
|
2011-07-14 06:13:52 +00:00
|
|
|
if (model){
|
2011-07-19 12:32:09 +00:00
|
|
|
import_comp = $("#import_compat option:selected").val()
|
2011-07-19 13:04:23 +00:00
|
|
|
var params = {"import_compat":parseInt(import_comp), "views_id": this.views_id, "parent_field_type" : record['field_type']}
|
|
|
|
self.rpc("/base_export/export/get_fields", {"model": model, "prefix": prefix, "name": name, "field_parent" : self.field_id, "params":params}, function (results) {
|
2011-07-14 06:13:52 +00:00
|
|
|
self.on_show_data(results);
|
|
|
|
});
|
2011-07-12 07:14:22 +00:00
|
|
|
}
|
2011-07-13 09:02:18 +00:00
|
|
|
}
|
2011-07-14 06:13:52 +00:00
|
|
|
} else if (is_loaded > 0) {
|
|
|
|
self.showcontent(self.field_id, true);
|
|
|
|
} else {
|
|
|
|
self.showcontent(self.field_id, false);
|
2011-07-13 09:02:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2011-07-11 05:03:35 +00:00
|
|
|
},
|
|
|
|
|
2011-07-13 09:02:18 +00:00
|
|
|
on_show_data: function(result) {
|
2011-07-11 05:03:35 +00:00
|
|
|
var self = this;
|
2011-07-14 07:09:45 +00:00
|
|
|
var current_tr = $("tr[id='treerow-" + self.field_id + "']");
|
2011-07-12 05:05:39 +00:00
|
|
|
if (current_tr.length >= 1){
|
2011-07-21 05:12:32 +00:00
|
|
|
current_tr.find('img').attr('src','/base_export/static/src/img/collapse.gif');
|
|
|
|
current_tr.after(QWeb.render('ExportTreeView-Secondary.children', {'fields': result}));
|
2011-07-12 05:05:39 +00:00
|
|
|
}
|
|
|
|
else{
|
2011-07-14 06:13:52 +00:00
|
|
|
$('#left_field_panel').append(QWeb.render('ExportTreeView-Secondary', {'fields': result}));
|
2011-07-12 05:05:39 +00:00
|
|
|
}
|
2011-07-21 08:44:20 +00:00
|
|
|
_.each(result, function(record) {
|
2011-07-22 12:08:26 +00:00
|
|
|
if(record.field_type == "one2many"){
|
|
|
|
var o2m_fld = $("tr[id^='treerow-" + record.id + "']").find('#tree-column');
|
|
|
|
o2m_fld.addClass("readonlyfield");
|
|
|
|
}
|
2011-07-22 09:50:36 +00:00
|
|
|
if ((record.required == true) || record.required == "True"){
|
|
|
|
var required_fld = $("tr[id^='treerow-" + record.id + "']").find('#tree-column');
|
|
|
|
required_fld.addClass("requiredfield");
|
|
|
|
}
|
2011-07-21 08:44:20 +00:00
|
|
|
$("img[id ^='parentimg-" + record.id +"']").click(function(){
|
|
|
|
self.on_click(this.id, result);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("tr[id^='treerow-" + record.id + "']").click(function(e){
|
2011-07-22 06:23:32 +00:00
|
|
|
if (e.shiftKey == true){
|
|
|
|
var frst_click,scnd_click = '';
|
|
|
|
if (self.row_index == 0){
|
|
|
|
self.row_index = this.rowIndex;
|
|
|
|
frst_click = $("tr[id^='treerow-']")[self.row_index-1];
|
|
|
|
$(frst_click).addClass("ui-selected");
|
|
|
|
}else{
|
|
|
|
if (this.rowIndex >=self.row_index){
|
|
|
|
for (i = (self.row_index-1); i < this.rowIndex; i++) {
|
|
|
|
scnd_click = $("tr[id^='treerow-']")[i];
|
2011-07-22 12:08:26 +00:00
|
|
|
if(!$(scnd_click).find('#tree-column').hasClass("readonlyfield")){
|
|
|
|
$(scnd_click).addClass("ui-selected");
|
|
|
|
}
|
2011-07-22 06:23:32 +00:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
for (i = (self.row_index-1); i >= (this.rowIndex-1); i--) {
|
|
|
|
scnd_click = $("tr[id^='treerow-']")[i];
|
2011-07-22 12:08:26 +00:00
|
|
|
if(!$(scnd_click).find('#tree-column').hasClass("readonlyfield")){
|
|
|
|
$(scnd_click).addClass("ui-selected");
|
|
|
|
}
|
2011-07-22 06:23:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.row_index = this.rowIndex;
|
|
|
|
|
|
|
|
$("tr[id^='treerow-" + record.id + "']").keyup(function (e) {
|
|
|
|
self.row_index = 0;
|
|
|
|
});
|
2011-07-22 12:08:26 +00:00
|
|
|
var o2m_selection = $("tr[id^='treerow-" + record.id + "']").find('#tree-column');
|
|
|
|
if ($(o2m_selection).hasClass("readonlyfield")){
|
|
|
|
return false;
|
|
|
|
}
|
2011-07-21 08:44:20 +00:00
|
|
|
var selected = $("tr.ui-selected");
|
|
|
|
if ($(this).hasClass("ui-selected") && (e.ctrlKey == true)){
|
|
|
|
$(this).find('a').blur();
|
|
|
|
$(this).removeClass("ui-selected");
|
2011-07-22 06:23:32 +00:00
|
|
|
}else if($(this).hasClass("ui-selected") && (e.ctrlKey == false) && (e.shiftKey == false)){
|
2011-07-21 08:44:20 +00:00
|
|
|
selected.find('a').blur();
|
|
|
|
selected.removeClass("ui-selected");
|
|
|
|
$(this).find('a').focus();
|
|
|
|
$(this).addClass("ui-selected");
|
2011-07-22 06:23:32 +00:00
|
|
|
}else if(!$(this).hasClass("ui-selected") && (e.ctrlKey == false) && (e.shiftKey == false)){
|
2011-07-21 08:44:20 +00:00
|
|
|
selected.find('a').blur();
|
|
|
|
selected.removeClass("ui-selected");
|
|
|
|
$(this).find('a').focus();
|
|
|
|
$(this).addClass("ui-selected");
|
|
|
|
}else if(!$(this).hasClass("ui-selected") && (e.ctrlKey == true)){
|
|
|
|
$(this).find('a').focus();
|
|
|
|
$(this).addClass("ui-selected");
|
|
|
|
}
|
2011-07-21 09:55:08 +00:00
|
|
|
return false;
|
2011-07-21 08:44:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$("tr[id^='treerow-" + record.id + "']").keydown(function (e) {
|
|
|
|
var keyCode = e.keyCode || e.which;
|
|
|
|
arrow = {left: 37, up: 38, right: 39, down: 40 };
|
|
|
|
switch (keyCode) {
|
|
|
|
case arrow.left:
|
|
|
|
if( jQuery(this).find('img').attr('src') == '/base_export/static/src/img/collapse.gif'){
|
|
|
|
self.on_click(this.id, result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case arrow.up:
|
|
|
|
var elem = this;
|
|
|
|
$(elem).removeClass("ui-selected");
|
|
|
|
while($(elem).prev().is(":visible") == false){
|
|
|
|
elem = $(elem).prev();
|
|
|
|
}
|
2011-07-22 12:08:26 +00:00
|
|
|
if(!$(elem).prev().find('#tree-column').hasClass("readonlyfield")){
|
|
|
|
$(elem).prev().addClass("ui-selected");
|
|
|
|
}
|
2011-07-21 08:44:20 +00:00
|
|
|
$(elem).prev().find('a').focus();
|
|
|
|
break;
|
|
|
|
case arrow.right:
|
|
|
|
if( jQuery(this).find('img').attr('src') == '/base_export/static/src/img/expand.gif'){
|
|
|
|
self.on_click(this.id, result);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case arrow.down:
|
|
|
|
var elem = this;
|
|
|
|
$(elem).removeClass("ui-selected");
|
|
|
|
while($(elem).next().is(":visible") == false){
|
|
|
|
elem = $(elem).next();
|
|
|
|
}
|
2011-07-22 12:08:26 +00:00
|
|
|
if(!$(elem).next().find('#tree-column').hasClass("readonlyfield")){
|
|
|
|
$(elem).next().addClass("ui-selected");
|
|
|
|
}
|
2011-07-21 08:44:20 +00:00
|
|
|
$(elem).next().find('a').focus();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2011-07-22 12:08:26 +00:00
|
|
|
$("tr[id^='treerow-" + record.id + "']").dblclick(function (e) {
|
|
|
|
var o2m_selection = $("tr[id^='treerow-" + record.id + "']").find('#tree-column');
|
|
|
|
if (! $(o2m_selection).hasClass("readonlyfield")){
|
|
|
|
var field_id = $(this).find("a").attr("id");
|
|
|
|
if(field_id){
|
|
|
|
self.add_field(field_id.split('-')[1], $(this).find("a").attr("string"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-07-07 10:01:04 +00:00
|
|
|
});
|
2011-07-14 06:13:52 +00:00
|
|
|
$('#fields_list').mouseover(function(event){
|
2011-07-12 13:12:21 +00:00
|
|
|
if(event.relatedTarget){
|
2011-07-21 08:44:20 +00:00
|
|
|
if (event.relatedTarget.attributes['id'] && event.relatedTarget.attributes['string']){
|
2011-07-12 13:12:21 +00:00
|
|
|
field_id = event.relatedTarget.attributes["id"]["value"]
|
|
|
|
if (field_id && field_id.split("-")[0] == 'export'){
|
2011-07-22 12:08:26 +00:00
|
|
|
if(!$("tr[id^='treerow-" + field_id.split("-")[1] + "']").find('#tree-column').hasClass("readonlyfield")){
|
|
|
|
self.add_field(field_id.split("-")[1], event.relatedTarget.attributes["string"]["value"]);
|
|
|
|
}
|
2011-07-12 13:12:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-07-11 11:45:37 +00:00
|
|
|
},
|
|
|
|
|
2011-07-12 07:14:22 +00:00
|
|
|
// show & hide the contents
|
|
|
|
showcontent: function (id, flag) {
|
2011-07-14 07:09:45 +00:00
|
|
|
var first_child = $("tr[id='treerow-" + id + "']").find('img')
|
2011-07-12 07:14:22 +00:00
|
|
|
if (flag) {
|
2011-07-21 05:12:32 +00:00
|
|
|
first_child.attr('src', '/base_export/static/src/img/expand.gif');
|
2011-07-12 07:14:22 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-07-21 05:12:32 +00:00
|
|
|
first_child.attr('src', '/base_export/static/src/img/collapse.gif');
|
2011-07-12 07:14:22 +00:00
|
|
|
}
|
2011-07-14 07:09:45 +00:00
|
|
|
var child_field = $("tr[id^='treerow-" + id +"/']")
|
2011-07-14 06:13:52 +00:00
|
|
|
var child_len = (id.split("/")).length + 1
|
2011-07-12 07:14:22 +00:00
|
|
|
for (var i = 0; i < child_field.length; i++) {
|
|
|
|
if (flag) {
|
|
|
|
$(child_field[i]).hide();
|
|
|
|
}
|
|
|
|
else {
|
2011-07-14 06:13:52 +00:00
|
|
|
if(child_len == (child_field[i].id.split("/")).length){
|
2011-07-21 05:12:32 +00:00
|
|
|
if( jQuery(child_field[i]).find('img').attr('src') == '/base_export/static/src/img/collapse.gif'){
|
|
|
|
jQuery(child_field[i]).find('img').attr('src', '/base_export/static/src/img/expand.gif')
|
2011-07-14 06:13:52 +00:00
|
|
|
}
|
|
|
|
$(child_field[i]).show();
|
|
|
|
}
|
2011-07-12 07:14:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-07-13 13:06:51 +00:00
|
|
|
add_field: function(field_id, string) {
|
2011-07-14 06:13:52 +00:00
|
|
|
var field_list = $('#fields_list')
|
|
|
|
if ( $("#fields_list option[value='" + field_id + "']") && !$("#fields_list option[value='" + field_id + "']").length){
|
|
|
|
field_list.append( new Option(string, field_id));
|
|
|
|
}
|
2011-07-07 10:01:04 +00:00
|
|
|
},
|
2011-07-12 10:21:18 +00:00
|
|
|
|
|
|
|
get_fields: function (){
|
|
|
|
var export_field = [];
|
2011-07-14 13:20:11 +00:00
|
|
|
$("#fields_list option").each(function(){
|
2011-07-12 10:21:18 +00:00
|
|
|
export_field.push(jQuery(this).val());
|
|
|
|
});
|
|
|
|
if (! export_field.length){
|
2011-07-18 12:49:40 +00:00
|
|
|
alert('Please select fields to save export list...');
|
2011-07-12 10:21:18 +00:00
|
|
|
}
|
2011-07-14 11:41:43 +00:00
|
|
|
return export_field;
|
2011-07-12 10:21:18 +00:00
|
|
|
},
|
2011-07-18 12:49:40 +00:00
|
|
|
on_click_export_data: function(){
|
|
|
|
var self = this;
|
|
|
|
var export_field = {};
|
|
|
|
var flag = true;
|
|
|
|
$("#fields_list option").each(function(){
|
|
|
|
export_field[jQuery(this).val()] = jQuery(this).text();
|
|
|
|
flag = false;
|
|
|
|
});
|
|
|
|
if (flag){
|
|
|
|
alert('Please select fields to export...');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
import_comp = $("#import_compat option:selected").val()
|
2011-07-22 10:42:02 +00:00
|
|
|
export_format = $("#export_format").val()
|
|
|
|
|
|
|
|
self.rpc("/base_export/export/export_data", {"model": self.dataset.model, "fields":export_field, 'ids': self.dataset.ids, 'domain': self.dataset.domain, "import_compat":parseInt(import_comp), "export_format" :export_format}, function(data){
|
|
|
|
window.location="data:text/csv/excel;charset=utf8," + data
|
2011-07-18 12:49:40 +00:00
|
|
|
self.close();
|
|
|
|
});
|
|
|
|
},
|
2011-07-13 05:26:02 +00:00
|
|
|
|
2011-07-13 07:16:41 +00:00
|
|
|
close: function() {
|
2011-07-13 09:02:18 +00:00
|
|
|
jQuery(this.$dialog).remove();
|
|
|
|
this._super();
|
2011-07-13 05:26:02 +00:00
|
|
|
},
|
|
|
|
|
2011-07-07 10:01:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
};
|