|
@ -19,48 +19,25 @@ |
|
|
//
|
|
|
//
|
|
|
//#############################################################################
|
|
|
//#############################################################################
|
|
|
|
|
|
|
|
|
openerp.web_export_view = function(openerp) { |
|
|
|
|
|
|
|
|
openerp.web_export_view = function(instance, m) { |
|
|
|
|
|
|
|
|
_t = openerp.web._t; |
|
|
|
|
|
|
|
|
var _t = instance.web._t, |
|
|
|
|
|
QWeb = instance.web.qweb; |
|
|
|
|
|
|
|
|
openerp.web.Sidebar = openerp.web.Sidebar.extend({ |
|
|
|
|
|
|
|
|
|
|
|
add_default_sections: function() { |
|
|
|
|
|
// IMHO sections should be registered objects
|
|
|
|
|
|
// as views and retrieved using a specific registry
|
|
|
|
|
|
// so that we don't have to override this
|
|
|
|
|
|
|
|
|
|
|
|
var self = this, |
|
|
|
|
|
view = this.widget_parent, |
|
|
|
|
|
view_manager = view.widget_parent, |
|
|
|
|
|
action = view_manager.action; |
|
|
|
|
|
if (this.session.uid === 1) { |
|
|
|
|
|
this.add_section(_t('Customize'), 'customize'); |
|
|
|
|
|
this.add_items('customize', [{ |
|
|
|
|
|
label: _t("Translate"), |
|
|
|
|
|
callback: view.on_sidebar_translate, |
|
|
|
|
|
title: _t("Technical translation") |
|
|
|
|
|
}]); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.add_section(_t('Other Options'), 'other'); |
|
|
|
|
|
this.add_items('other', [ |
|
|
|
|
|
{ |
|
|
|
|
|
label: _t("Export"), |
|
|
|
|
|
callback: view.on_sidebar_export |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
label: _t("Export current view"), |
|
|
|
|
|
callback: this.on_sidebar_export_view |
|
|
|
|
|
} |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
instance.web.Sidebar.include({ |
|
|
|
|
|
redraw: function() { |
|
|
|
|
|
var self = this; |
|
|
|
|
|
this._super.apply(this, arguments); |
|
|
|
|
|
self.$el.find('.oe_sidebar').append(QWeb.render('AddExportViewMain', {widget: self})); |
|
|
|
|
|
self.$el.find('.oe_sidebar_export_view_xls').on('click', self.on_sidebar_export_view_xls); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
on_sidebar_export_view: function() { |
|
|
|
|
|
|
|
|
on_sidebar_export_view_xls: function() { |
|
|
// Select the first list of the current (form) view
|
|
|
// Select the first list of the current (form) view
|
|
|
// or assume the main view is a list view and use that
|
|
|
// or assume the main view is a list view and use that
|
|
|
var self = this, |
|
|
var self = this, |
|
|
view = this.widget_parent; // valid for list view
|
|
|
|
|
|
|
|
|
view = this.getParent(), |
|
|
|
|
|
columns = view.visible_columns; |
|
|
if (view.widget_children) { |
|
|
if (view.widget_children) { |
|
|
view.widget_children.every(function(child) { |
|
|
view.widget_children.every(function(child) { |
|
|
if (child.field && child.field.type == 'one2many') { |
|
|
if (child.field && child.field.type == 'one2many') { |
|
@ -74,7 +51,6 @@ openerp.web_export_view = function(openerp) { |
|
|
return true; |
|
|
return true; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
var columns = view.visible_columns; |
|
|
|
|
|
export_columns_keys = []; |
|
|
export_columns_keys = []; |
|
|
export_columns_names = []; |
|
|
export_columns_names = []; |
|
|
$.each(columns,function(){ |
|
|
$.each(columns,function(){ |
|
@ -84,13 +60,15 @@ openerp.web_export_view = function(openerp) { |
|
|
export_columns_names.push(this.string); |
|
|
export_columns_names.push(this.string); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
rows = view.$element.find('.ui-widget-content tr'); |
|
|
|
|
|
|
|
|
rows = view.$el.find('.oe_list_content > tbody > tr'); |
|
|
export_rows = []; |
|
|
export_rows = []; |
|
|
$.each(rows,function(){ |
|
|
$.each(rows,function(){ |
|
|
$row = $(this); |
|
|
$row = $(this); |
|
|
// find only rows with data
|
|
|
// find only rows with data
|
|
|
if($row.attr('data-id')){ |
|
|
if($row.attr('data-id')){ |
|
|
export_row = []; |
|
|
export_row = []; |
|
|
|
|
|
checked = $row.find('th input[type=checkbox]').attr("checked"); |
|
|
|
|
|
if (checked === "checked"){ |
|
|
$.each(export_columns_keys,function(){ |
|
|
$.each(export_columns_keys,function(){ |
|
|
cell = $row.find('td[data-field="'+this+'"]').get(0); |
|
|
cell = $row.find('td[data-field="'+this+'"]').get(0); |
|
|
text = cell.text || cell.textContent || cell.innerHTML || ""; |
|
|
text = cell.text || cell.textContent || cell.innerHTML || ""; |
|
@ -98,6 +76,7 @@ openerp.web_export_view = function(openerp) { |
|
|
}); |
|
|
}); |
|
|
export_rows.push(export_row); |
|
|
export_rows.push(export_row); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
$.blockUI(); |
|
|
$.blockUI(); |
|
|
view.session.get_file({ |
|
|
view.session.get_file({ |
|
@ -113,4 +92,4 @@ openerp.web_export_view = function(openerp) { |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}; |