Bläddra i källkod

[FIX] Corregir grafico Adiccionar mensaje de configuraciones

Adrielso 7 år sedan
förälder
incheckning
3dad6f3893

+ 139 - 28
static/src/js/eiru_reporting.js

@@ -10,41 +10,40 @@ openerp.eiru_reporting = function (instance, local) {
         },
         reports: [
             {
-                title: 'Resumen de Ingreso',
-                description: 'Permite visualizar de forma global el ingreso obtenido de la empresa.',
+                title: 'Resumen de ingresos',
+                description: 'Permite visualizar de forma global los ingresos obtenidos por la empresa.',
                 action: 'ReportResumenIngreso'
             },
             {
-                title: 'Resumen de Egreso',
-                description: 'Permite visualizar de forma global el Egreso de la Empresa.',
+                title: 'Resumen de egresos',
+                description: 'Permite visualizar de forma global los egresos realizado por la empresa.',
                 action: 'ReportResumenEngreso'
             },
             {
-                title: 'Análisis de Utilidad',
-                description: 'Permite visualizar la utilidad de los productos en las facturas.',
+                title: 'Utilidad de facturas detalladas',
+                description: 'Permite visualizar la ganancia de cada ítem de las facturas detalladamente.',
                 action: 'ReportInvoiceUtility'
             },
             {
-                title: 'Listado de Stock por Ubicacion',
-                description: 'Permite visualizar un listado de productos activos.',
-                action: 'ReportStockLocation'
-            },
-            {
-                title: 'Listado de Compras',
-                description: 'Permite visualizar un listado de Compras.',
+                title: 'Histórico de compras',
+                description: 'Permite visualizar un histórico de compras realizado por la empresa.',
                 action: 'AllPurchases'
             },
             {
-                title: 'Listado de Gastos',
-                description: 'Permite visualizar un listado de Gastos.',
+                title: 'Histórico de gastos',
+                description: 'Permite visualizar un histórico de gastos realizado por la empresa.',
                 action: 'ReposrtExpenses'
+            },
+            {
+                title: 'Listado de productos por ubicación',
+                description: 'Permite visualizar un listado de productos activos.',
+                action: 'ReportStockLocation'
             }
         ],
         start: function () {
         },
 
         clickOnReport: function (e) {
-
             var templateName = this.$el.find(e.target).val();
             this.renderReport(templateName);
         },
@@ -97,6 +96,7 @@ openerp.eiru_reporting = function (instance, local) {
         // volver
         volver: function(){
             this.$el.find('#volver').empty();
+            this.$el.find('#grafico').empty();
             this.$el.find('.bootstrap-table').show({
                 effect: 'drop',
                 direction: 'down',
@@ -467,7 +467,7 @@ openerp.eiru_reporting = function (instance, local) {
                     pdfDoc.setFontSize(12);
                     pdfDoc.setFontStyle('bold');
                     pdfDoc.setTextColor(40);
-                    pdfDoc.text('Análisis de Utilidad '+ sucusal, data.settings.margin.left, 10);
+                    pdfDoc.text('Utilidad de facturas detalladas por '+ sucusal, data.settings.margin.left, 10);
 
                     if(desde.length > 0 || hasta.length > 0){
                       var fecha='';
@@ -498,13 +498,17 @@ openerp.eiru_reporting = function (instance, local) {
             if (typeof pdfDoc.putTotalPages === 'function') {
                 pdfDoc.putTotalPages(totalPagesExp);
             }
-            pdfDoc.save('Analisis de utilidad.pdf')
+            pdfDoc.save('Utilidad de facturas detalladas.pdf')
         },
         // Chart Filter
         fectCharFilter: function(){
           var self = this;
           var dataBody=[];
           var dataHeader=[];
+
+          var canvas="<canvas id='graf_resume'></canvas>";
+          this.$el.find('#grafico').append(canvas);
+
           _.each(self.accountJournal, function(journal){
             dataHeader.push(journal.name);
             var utility=_.reduce(_.map(_.filter(self.rowsData, function (inv){ return inv.journal_id == journal.id}),function(item){
@@ -526,18 +530,13 @@ openerp.eiru_reporting = function (instance, local) {
         },
         // Chart
         drawChart: function (dataHeader,dataBody) {
-            var company = _.map(self.resCompany, function (map) {
-                return map.currency_id[1];
-            });
-            var barChart = new Chart(this.$el.find('canvas'), {
-              // type:"doughnut",
-
-                type: 'bar',
+            var barChart = new Chart(this.$el.find('#graf_resume'), {
+                type: 'doughnut',
                 data: {
                     labels: dataHeader,
                     datasets: [
                         {
-                            label: "Utilidad "+company,
+                            labels: dataHeader,
                             backgroundColor: [
                                 'rgba(255, 99, 132, 0.2)',
                                 'rgba(54, 162, 235, 0.2)',
@@ -556,7 +555,13 @@ openerp.eiru_reporting = function (instance, local) {
                             data: dataBody,
                         }
                     ]
-                }
+                },
+                options: {
+                    maintainAspectRatio: false,
+                    layout: {
+                        padding: 30
+                    }
+                },
             });
         },
     });
@@ -569,6 +574,7 @@ openerp.eiru_reporting = function (instance, local) {
         dataVoucher:[],
         currencyRate:[],
         companyCurrency:[],
+        modules:[],
 
         events:{
             'click  #toolbar > button' : 'clickOnAction',
@@ -589,6 +595,49 @@ openerp.eiru_reporting = function (instance, local) {
             self.fecthFecha();
             self.fecthInitial();
         },
+        // Redirecionar
+        renderReport: function () {
+            var self = this;
+
+            var container = this.$el.closest('.oe_form_sheet.oe_form_sheet_width');
+            this.$el.closest('.report_view').remove();
+            container.find('.report_view').show({
+                effect: 'fade',
+                duration: 200,
+            });
+        },
+        // Verificar el modelo
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.modules,function(item){return item === model});
+        },
+        // Lanzar el mensaje
+        showMensaje : function(modelos){
+            $("#dialog" ).dialog({
+                autoOpen: true,
+                resizable: false,
+                modal: true,
+                title: 'Atención',
+                width: 500,
+                open: function() {
+                    $(this).html('Lo sentimos , pero no contás con las configuraciones adecuado para manipular este  informe.\nPóngase en contacto con el administrador del sistema (referencia : '+modelos+' )');
+                },
+                show: {
+                    effect: "fade",
+                    duration: 200
+                },
+                hide: {
+                    effect: "fade",
+                    duration: 200
+                },
+                buttons: {
+                    Aceptar: function() {
+                        $(this).dialog('close');
+                    }
+                }
+            });
+            return
+        },
         // Fecha
         fecthFecha: function() {
             var to;
@@ -624,6 +673,8 @@ openerp.eiru_reporting = function (instance, local) {
         //  Metodo inicial
         fecthInitial: function(){
             var self = this;
+            self.modules = instance._modules;
+
             self.fecthJournalStore().then(function(accountJournal){
                 self.accountJournal=accountJournal;
                 return accountJournal;
@@ -650,13 +701,21 @@ openerp.eiru_reporting = function (instance, local) {
                 self.companyCurrency = companyCurrency;
                 return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
             });
+            return self.renderReport()
         },
         // Journal
         fecthJournalStore: function(){
             var self = this;
             var defer = $.Deferred();
+            var modules = self.checkModel('multi_store');
+            if (modules.length <= 0){
+                self.showMensaje('multi_store');
+                return defer;
+            }
+
             var journal = new instance.web.Model('res.store');
             var field=['id', 'name','out_invoice_id','journal_ids'];
+
             journal.query(field).order_by('id').all().then(function(results){
                 defer.resolve(results);
             });
@@ -1016,6 +1075,7 @@ openerp.eiru_reporting = function (instance, local) {
         dataVoucher:[],
         currencyRate:[],
         resCompany:[],
+        modules:[],
         events:{
           'click #toolbar > button' : 'clickOnAction',
           'change #current-journal': 'fectSearch',
@@ -1035,6 +1095,49 @@ openerp.eiru_reporting = function (instance, local) {
             self.fecthFecha();
             self.fecthInitial();
         },
+        // Redirecionar
+        renderReport: function () {
+            var self = this;
+
+            var container = this.$el.closest('.oe_form_sheet.oe_form_sheet_width');
+            this.$el.closest('.report_view').remove();
+            container.find('.report_view').show({
+                effect: 'fade',
+                duration: 200,
+            });
+        },
+        // Verificar el modelo
+        checkModel : function(model){
+            var self = this;
+            return _.filter(self.modules,function(item){return item === model});
+        },
+        // Lanzar el mensaje
+        showMensaje : function(modelos){
+            $("#dialog" ).dialog({
+                autoOpen: true,
+                resizable: false,
+                modal: true,
+                title: 'Atención',
+                width: 500,
+                open: function() {
+                    $(this).html('Lo sentimos , pero no contás con las configuraciones adecuado para manipular este  informe.\nPóngase en contacto con el administrador del sistema (referencia : '+modelos+' )');
+                },
+                show: {
+                    effect: "fade",
+                    duration: 200
+                },
+                hide: {
+                    effect: "fade",
+                    duration: 200
+                },
+                buttons: {
+                    Aceptar: function() {
+                        $(this).dialog('close');
+                    }
+                }
+            });
+            return
+        },
         // Fecha
         fecthFecha: function() {
             var to;
@@ -1070,6 +1173,7 @@ openerp.eiru_reporting = function (instance, local) {
         //  Metodo inicial
         fecthInitial: function(){
             var self = this;
+            self.modules = instance._modules;
             self.fecthJournalStore().then(function(accountJournal){
                 self.accountJournal=accountJournal;
                 return accountJournal;
@@ -1096,7 +1200,7 @@ openerp.eiru_reporting = function (instance, local) {
                 self.resCompany = resCompany;
                 return self.fecthDataVoucher(self.accountVoucher,self.accountJournal);
             });
-            return false;
+            return self.renderReport();
         },
         // company_curency
         fecthComanyCurrency: function(){
@@ -1114,8 +1218,15 @@ openerp.eiru_reporting = function (instance, local) {
         fecthJournalStore: function(){
             var self = this;
             var defer = $.Deferred();
+            var modules = self.checkModel('multi_store');
+            if (modules.length <= 0){
+                self.showMensaje('multi_store');
+                return defer;
+            }
+
             var journal = new instance.web.Model('res.store');
             var field=['id', 'name','out_invoice_id','journal_ids'];
+
             journal.query(field).order_by('id').all().then(function(results){
                 defer.resolve(results);
             });

+ 4 - 3
static/src/reports/report_invoice_utility.xml

@@ -3,7 +3,7 @@
       <t t-name="ReportInvoiceUtility">
         <div class="report_view">
           <div class="reporting_page_header">
-            <h1>Analisis de Utilidad</h1>
+            <h1>Utilidad de facturas detalladas</h1>
             <div id="volver"></div>
           </div>
           <div id="toolbar">
@@ -30,7 +30,7 @@
             <thead>
               <tr>
                 <th data-field="number" data-sortable="true">Factura</th>
-                <th data-field="name" >Prodcuto</th>
+                <th data-field="name" >Producto</th>
                 <th data-field="quantity" data-sortable="true" data-align="right">Cat.</th>
                 <th data-field="price_unity" data-sortable="true" data-align="right">Precio Unitario</th>
                 <th data-field="standar_price" data-sortable="true" data-align="right">Precio de Costo</th>
@@ -40,7 +40,8 @@
               </tr>
             </thead>
         </table>
-        <canvas></canvas>
+        <!-- <canvas></canvas> -->
+        <div class="widget-content" id="grafico"></div>
         <div id="dialog"></div>
       </div>
       </t>

+ 0 - 1
static/src/reports/report_resumen_egresos.xml

@@ -38,7 +38,6 @@
                     </tr>
                 </thead>
             </table>
-
             <div class="widget-content" id="grafico">
             </div>
             <div id="dialog"></div>