Browse Source

[FIX] ajustes varios

Rodney Elpidio Enciso Arias 6 years ago
parent
commit
6459dafe96

+ 1 - 8
__openerp__.py

@@ -5,14 +5,7 @@
     'category': 'report',
     'version': '1.1',
     'depends': [
-        'base',
-        'product',
-        'account',
-        'stock',
-        'eiru_assets',
-        'account_journal_active',
-        'multi_store',
-        'multi_store_stock',
+        'eiru_reports_sales',
     ],
     'qweb': [
         'static/src/xml/*.xml',

BIN
controller/helpers/__init__.pyc


+ 1 - 292
static/src/js/chart.js

@@ -3,298 +3,7 @@ function chart(reporting) {
 
     var model = openerp;
 
-    reporting.ReportSaleChartWidget = reporting.Base.extend({
+    reporting.ReportExpenseChartWidget = reporting.Base.extend({
 
-        BuildLineChart: function (label,data,CurrencyBase) {
-            var self = this;
-            Chart.scaleService.updateScaleDefaults('linear', {
-                ticks: {
-                    callback: function(tick) {
-                        return tick.toLocaleString('de-DE');
-                    }
-                }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-            var chart = new Chart($(".reporting-chart"), {
-                type: 'line',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: false,
-                            data: data,
-                            backgroundColor: '#bbdefb',
-                            borderColor: '#0288d1',
-                            borderWidth: 1,
-                            fill: true,
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    responsiveAnimationDuration:10,
-                    maintainAspectRatio:false,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 0,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    events: ['click'],
-                    tooltips: {
-                        callbacks: {
-                            label: function(tooltipItem, data) {
-                                var label = data.datasets[tooltipItem.datasetIndex].label || '';
-
-                                if (label) {
-                                    label += ': ';
-                                }
-                                label += accounting.formatMoney(tooltipItem.yLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
-                                return label;
-                            }
-                        }
-                    }
-                }
-            });
-        },
-
-        BuildBarChart: function (data,CurrencyBase,label,body) {
-            var self = this;
-            Chart.scaleService.updateScaleDefaults('linear', {
-              ticks: {
-                callback: function(tick) {
-                    return tick.toLocaleString('de-DE');
-                }
-              }
-            });
-            Chart.defaults.global.tooltips.callbacks.label = function(tooltipItem, data) {
-                var dataset = data.datasets[tooltipItem.datasetIndex];
-                var datasetLabel = dataset.label || '';
-                return datasetLabel +  dataset.data[tooltipItem.index].toLocaleString('de-DE');
-            };
-
-            var color = [];
-            color.push('#BCCEF4');
-            color.push('#A9E5E3');
-            color.push('#A0D995');
-            color.push('#C5D084');
-            color.push('#FAE187');
-            color.push('#FFBD82');
-            color.push('#FFA8B8');
-            color.push('#E5BEDD');
-            color.push('#C4ABFE');
-            color.push('#D8D8D8');
-
-            var chart = new Chart($(".reporting-chart"), {
-                type: 'horizontalBar',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: false,
-                            data: body,
-                            backgroundColor: color,
-                            fill: true,
-                        }
-                    ]
-                },
-                options: {
-                    responsive: true,
-                    responsiveAnimationDuration:10,
-                    maintainAspectRatio:false,
-                    title: {
-                        display: false,
-                    },
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                       display: false,
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 0,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    tooltips: {
-                        callbacks: {
-                            label: function(tooltipItem, data) {
-                                var label = data.datasets[tooltipItem.datasetIndex].label || '';
-
-                                if (label) {
-                                    label += ': ';
-                                }
-                                label += accounting.formatMoney(tooltipItem.xLabel, CurrencyBase.symbol, CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator);
-                                return label;
-                            }
-                        }
-                    },
-                    events: ['click'],
-                }
-            });
-        },
-
-        BuildPieChart: function (data,CurrencyBase,label,body) {
-            var self = this;
-
-            var color = [];
-            color.push('#BCCEF4');
-            color.push('#A9E5E3');
-            color.push('#A0D995');
-            color.push('#C5D084');
-            color.push('#FAE187');
-            color.push('#FFBD82');
-            color.push('#FFA8B8');
-            color.push('#E5BEDD');
-            color.push('#C4ABFE');
-            color.push('#D8D8D8');
-            color.push('#f3e5f5');
-
-            var chart = new Chart($(".reporting-pie-chart"), {
-                type: 'pie',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: false,
-                            data: body,
-                            backgroundColor: color,
-                            fill: true,
-                        }
-                    ]
-                },
-
-                options: {
-                    responsive: true,
-                    responsiveAnimationDuration:10,
-                    maintainAspectRatio:false,
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                        position: 'right',
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 0,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    tooltips: {
-                        callbacks: {
-                            label: function(tooltipItem, data) {
-                                var label = data.labels[tooltipItem.index] || '';
-                                if (label) {
-                                    label += ': ';
-                                }
-                                label += accounting.formatMoney(data.datasets[0].data[tooltipItem.index],{
-                                    symbol: "%",
-                                    format: "%v%s",
-                                    precision: 2,
-                                    thousand: ".",
-                                    decimal: ","
-                                });
-                                return label;
-                            }
-                        }
-                    },
-                    events: ['click'],
-                }
-            });
-        },
-
-        BuildDoughnutChart: function (data,CurrencyBase,label,body) {
-            var self = this;
-
-            var color = [];
-            color.push('#BCCEF4');
-            color.push('#A9E5E3');
-            color.push('#A0D995');
-            color.push('#C5D084');
-            color.push('#FAE187');
-            color.push('#FFBD82');
-            color.push('#FFA8B8');
-            color.push('#E5BEDD');
-            color.push('#C4ABFE');
-            color.push('#D8D8D8');
-
-            var chart = new Chart($(".reporting-doughnut-chart"), {
-                type: 'doughnut',
-                data: {
-                    labels: label,
-                    datasets: [
-                        {
-                            label: false,
-                            data: body,
-                            backgroundColor: color,
-                            fill: true,
-                        }
-                    ]
-                },
-
-                options: {
-                    responsive: true,
-                    responsiveAnimationDuration:10,
-                    maintainAspectRatio:false,
-                    hover: {
-                        mode: 'nearest',
-                        intersect: true
-                    },
-                    legend: {
-                        position: 'left',
-                    },
-                    layout: {
-                        padding: {
-                            top: 0,
-                            bottom: 0,
-                            left : 0,
-                            rigth: 0,
-                        }
-                    },
-                    tooltips: {
-                        callbacks: {
-                            label: function(tooltipItem, data) {
-                                var label = data.labels[tooltipItem.index] || '';
-                                if (label) {
-                                    label += ': ';
-                                }
-                                label += accounting.formatMoney(data.datasets[0].data[tooltipItem.index],{
-                                    symbol: "%",
-                                    format: "%v%s",
-                                    precision: 2,
-                                    thousand: ".",
-                                    decimal: ","
-                                });
-                                return label;
-                            }
-                        }
-                    },
-                    events: ['click'],
-                }
-            });
-        },
     });
 }

+ 1 - 129
static/src/js/pdf.js

@@ -3,135 +3,7 @@ function pdf(reporting) {
 
     var model = openerp;
 
-    reporting.ReportSalePdfWidget = reporting.Base.extend({
-        drawPDF: function (getColumns,row,ResCompany,pdf_title,pdf_type,pdf_name,pdf_columnStyles,filter) {
-            var self = this;
-            var base64Img = 'data:image/png;base64,' + ResCompany.logo;
-            var hoy = moment().format('DD/MM/YYYY');
-            var totalPagesExp = "{total_pages_count_string}";
-            var pdfDoc = new jsPDF(pdf_type);
-            var y_position = 27;
-            var y_position2 = 27;
-            //LOGO
-            pdfDoc.addImage(base64Img, 'png', 7, 2, 0, 15);
-            //FECHA
-            pdfDoc.setFontSize(13);
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.setTextColor(40);
-            pdfDoc.text(pdfDoc.internal.pageSize.getWidth() - 35, 12,hoy);
-            //TITULO
-            pdfDoc.setFontSize(15);
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.setTextColor('#0288d1');
-            pdfDoc.autoTableText(pdf_title, pdfDoc.internal.pageSize.getWidth() - 12, 18, {
-                halign: 'right',
-                valign: 'middle'
-            });
-            pdfDoc.setLineWidth(0.5);
-            pdfDoc.setDrawColor('#424242');
-            pdfDoc.line(10, 22, pdfDoc.internal.pageSize.getWidth() - 10 , 22);
-            var i = 0;
-            var col1_title;
-            var col1_value;
-            var col2_title;
-            var col2_value;
-            if(pdf_type == 'l'){
-                col1_title = 15;
-                col1_value = 55;
-                col2_title = 150;
-                col2_value = 190;
-            }
-            else{
-                col1_title = 10;
-                col1_value = 50;
-                col2_title = 110;
-                col2_value = 150;
-            }
-            if(filter.length >0){
-                _.each(filter,function(item){
-                    if(i<4){
-                        self.addFilter(pdfDoc,item.title,item.value,col1_title,col1_value,y_position);
-                        y_position = y_position + 5;
-                    }else{
-                        self.addFilter(pdfDoc,item.title,item.value,col2_title,col2_value,y_position2);
-                        y_position2 = y_position2 + 5;
-                    }
-                    i++;
-                });
-                pdfDoc.setLineWidth(0.5);
-                pdfDoc.setDrawColor('#424242');
-                if(y_position >= y_position2){
-                    y_position = y_position;
-                    pdfDoc.line(10, y_position, pdfDoc.internal.pageSize.getWidth() - 10 , y_position);
-                }else{
-                    y_position = y_position2;
-                    pdfDoc.line(10, y_position2, pdfDoc.internal.pageSize.getWidth() - 10 , y_position2);
-                }
-            }
-            pdfDoc.autoTable(getColumns, row, {
-                startY: y_position + 5,
-                theme: 'grid',
-                styles: {
-                    overflow: 'linebreak',
-                    columnWidth: 'auto',
-                    fontSize: 7,
-                },
-                headerStyles: {
-                    fillColor: [76, 133, 248],
-                    fontSize: 9
-                },
-                columnStyles: pdf_columnStyles,
-                margin: { horizontal: 7},
-                drawCell: function(cell, opts) {
-                    var rows = opts.table.rows;
-                    if (opts.row.index == rows.length - 1) {
-                      pdfDoc.setFontStyle('bold');
-                    }
-                },
-                addPageContent: function (data) {
+    reporting.ReportExpensePdfWidget = reporting.Base.extend({
 
-                //FOOTER
-                    var str = "Página " + data.pageCount;
-                    if (typeof pdfDoc.putTotalPages === 'function') {
-                        str = str + " de " + totalPagesExp;
-                    }
-                    pdfDoc.setFontSize(9);
-                    pdfDoc.setFontStyle('bold');
-                    pdfDoc.setTextColor(40);
-                    var pageHeight = pdfDoc.internal.pageSize.height || pdfDoc.internal.pageSize.getHeight();
-                    pdfDoc.autoTableText(str, pdfDoc.internal.pageSize.getWidth() - 35, pageHeight - 5, {
-                      halign: 'rigth',
-                      valign: 'middle'
-                    });
-                }
-            });
-            if (typeof pdfDoc.putTotalPages === 'function') {
-                pdfDoc.putTotalPages(totalPagesExp);
-            }
-            row.pop();
-            if(model.printer_bridge){
-                var data = pdfDoc.output('datauristring');
-                model.printer_bridge.print(data);
-                return;
-            }
-            pdfDoc.save(pdf_name + hoy + '.pdf');
-        },
-
-        addFilter: function(pdfDoc,title,value,x_position_title,x_position_value,y_position){
-            pdfDoc.setFontSize(10);
-            pdfDoc.setTextColor('#424242');
-            pdfDoc.setFontStyle('bold');
-            pdfDoc.autoTableText(title+':', x_position_title, y_position, {
-                halign: 'left',
-                valign: 'middle'
-            });
-            pdfDoc.setFontSize(10);
-            pdfDoc.setTextColor('#424242');
-            pdfDoc.setFontStyle('normal');
-            pdfDoc.autoTableText(value, x_position_value, y_position, {
-                halign: 'left',
-                valign: 'middle'
-            });
-        },
     });
 }

+ 3 - 3
static/src/js/reports/report_purchase.js

@@ -443,9 +443,9 @@ function report_purchase(reporting){
                     CONFIGURACION DEL PDF
                 ============================================================
                 */
-                var pdf_title = 'Facturas de Compra.';
+                var pdf_title = 'Facturas de Compras.';
                 var pdf_type = '';
-                var pdf_name = 'facturas_de_compra_';
+                var pdf_name = 'facturas_de_compras_';
                 var pdf_columnStyles = {
                     number:{columnWidth: 30,halign:'left'},
                     origin:{columnWidth: 15, halign:'center'},
@@ -463,7 +463,7 @@ function report_purchase(reporting){
                 ============================================================
                 */
                 var filter = self.getFilter();
-                var pdf = new reporting.ReportSalePdfWidget(self);
+                var pdf = new model.eiru_reports_sales.ReportSalePdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
                     row,

+ 3 - 3
static/src/js/reports/report_purchase_analytic.js

@@ -565,9 +565,9 @@ function report_purchase_analytic(reporting){
                     CONFIGURACION DEL PDF
                 ============================================================
                 */
-                var pdf_title = 'Analisis de Compra.';
+                var pdf_title = 'Analisis de Compras.';
                 var pdf_type = 'l';
-                var pdf_name = 'analisis_de_compra_';
+                var pdf_name = 'analisis_de_compras_';
                 var pdf_columnStyles = {
                     number:{columnWidth: 30, halign:'center'},
                     date:{columnWidth: 20, halign:'center'},
@@ -586,7 +586,7 @@ function report_purchase_analytic(reporting){
                 ============================================================
                 */
                 var filter = self.getFilter();
-                var pdf = new reporting.ReportSalePdfWidget(self);
+                var pdf = new model.eiru_reports_sales.ReportSalePdfWidget(self);
                 pdf.drawPDF(
                     _.flatten(getColumns),
                     row,