|
@@ -1,12 +1,33 @@
|
|
|
openerp.dropdown_menu = function (instance, local) {
|
|
|
"use strict";
|
|
|
|
|
|
- local.WelcomeWidget = instance.Widget.extend({
|
|
|
+ local.MiniReporte = instance.Widget.extend({
|
|
|
+ fields: ['name', 'display_name', 'mobile', 'phone', 'email'],
|
|
|
+ init: function(parent, modelo, ids_seleccionados) {
|
|
|
+ this._super(parent);
|
|
|
+
|
|
|
+ this.modelo = modelo;
|
|
|
+ this.ids_seleccionados = ids_seleccionados;
|
|
|
+ },
|
|
|
start: function() {
|
|
|
- if (window) {
|
|
|
- window.alert('Hola desde un menu muito louco')
|
|
|
- }
|
|
|
- }
|
|
|
+ var self = this;
|
|
|
+
|
|
|
+ this.obtener_clientes().then(function (clientes) {
|
|
|
+ self.crear_pdf(clientes);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ obtener_clientes: function () {
|
|
|
+ var Partner = new instance.web.Model('res.partner');
|
|
|
+ return Partner.query(this.fields).filter([['id', 'in', this.ids_seleccionados]]).all()
|
|
|
+ },
|
|
|
+ crear_pdf: function (clientes) {
|
|
|
+ var documento = new jsPDF();
|
|
|
+ documento.autoTable(this.fields, _.map(clientes, function (cliente) {
|
|
|
+ return _.values(cliente);
|
|
|
+ }));
|
|
|
+
|
|
|
+ documento.output('reporte_de_clientes_' + Date.now() + '.pdf', 'dataurlnewwindow');
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
if (instance.web && instance.web.ListView) {
|
|
@@ -16,12 +37,14 @@ openerp.dropdown_menu = function (instance, local) {
|
|
|
|
|
|
if (this.model != 'res.partner') return
|
|
|
|
|
|
+ var self = this;
|
|
|
+
|
|
|
this.sidebar.add_items('print', [
|
|
|
{
|
|
|
- label: 'Menu muito louco',
|
|
|
+ label: 'Imprimir clientes',
|
|
|
classname: 'oe_sidebar_print',
|
|
|
callback: function () {
|
|
|
- var widget = new local.WelcomeWidget(this);
|
|
|
+ var widget = new local.MiniReporte(self, self.model, self.get_selected_ids());
|
|
|
widget.start()
|
|
|
}
|
|
|
}
|