Sfoglia il codice sorgente

[ADD] Nuevo modal para visualizar los detalles y mejoras en la llamada de los formulario

adrielso 7 anni fa
parent
commit
9fe67569be

+ 11 - 0
static/src/css/dashboard.css

@@ -65,3 +65,14 @@
 .grid-stack-item-content.dashboard > .widget-content > a:hover, .widget-footer > a:hover {
     cursor: pointer;
 }
+
+
+/*.table_paint_first_row > tbody > tr > td:nth-child(1):hover{*/
+.expired-account-modal .table-row-select {
+     background: #d4e2f3  !important;
+    /*cursor:pointer;*/
+}
+
+.expired-account-modal table tbody tr td:nth-child(1){
+    display: none;
+}

+ 86 - 12
static/src/js/widgets/expired_account_counters.js

@@ -2,6 +2,7 @@ function expired_account_counters (widget) {
     "use strict";
 
     var model = openerp;
+    var Qweb = openerp.web.qweb;
 
     widget.ExpiredAccountCountersWidget = widget.Base.extend({
         template: 'ExpiredAccountCounters',
@@ -9,6 +10,7 @@ function expired_account_counters (widget) {
         moveLine : [],
         resCompany : [],
         resCurrecy :[],
+        modelId:[],
 
         events: {
             'click a': 'showCustomers',
@@ -47,9 +49,24 @@ function expired_account_counters (widget) {
                 return self.fetchResCurrecy(resCompany);
             }).then(function (resCurrecy){
                 self.resCurrecy = resCurrecy;
+                return self.fetchGetModelId();
+            }).then(function(modelId){
+                self.modelId= modelId;
                 return self.fetchReduceMoveLine();
             });
         },
+        // getModelId
+        fetchGetModelId: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var irModelData = new model.web.Model('ir.model.data');
+            var getObtjectReference = irModelData.get_func('get_object_reference');
+
+            this.alive(getObtjectReference('account', 'invoice_form')).then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Partner
         fetchPartner: function () {
             var self = this;
@@ -71,7 +88,7 @@ function expired_account_counters (widget) {
             var move_id = _.flatten(_.map(partner, function (map) {
                 return map.unreconciled_aml_ids
             }));
-            var field =['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity'];
+            var field =['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity','invoice','ref'];
             var domain=[['credit', '<=', 0],['id', 'in', move_id],['date_maturity', '<', hoy]];
             var moveLine = new model.web.Model('account.move.line');
 
@@ -142,18 +159,75 @@ function expired_account_counters (widget) {
 
         showCustomers: function (e) {
             var self = this;
-            var hoy =moment().format('YYYY-MM-DD');
-            var move_id = _.flatten(_.map(self.moveLine, function (map) {
-                return map.id;
-            }));
+            if (self.moveLine <=0)
+                return
+
+            var moneda = self.resCurrecy.shift();
+            var newmoveLine = self.moveLine;
+            var titleData=[
+                {
+                    title:"Deudas atrasadas"
+                }
+            ];
+            var headerModal = [
+                {
+                    title:"Cliente"
+                },
+                {
+                    title:"Numero de Factura"
+                },
+                {
+                    title:"Vencimiento"
+                },
+                {
+                    title:"Monto "
+                }
+            ];
+
+            var modal = Qweb.render('ExpiredAccountCountersModal', {
+                data : newmoveLine,
+                dataThead : headerModal,
+                modalTitle : titleData
+            });
+
+            $('.openerp_webclient_container').after(modal);
+            $('.expired-account-modal').modal()
+            $('.expired-account-modal').on('hidden.bs.modal', function (e) {
+                self.removeModal(e);
+            })
+
+            var contenido = $('.expired-account-modal').find('.table-tbody');
+            contenido.click(function (e) {
+                $(contenido).find('tr').removeClass('table-row-select');
+                $(e.target).closest('tr').addClass('table-row-select');
+                var chirdren_id =$(e.target).closest('tr').children()[0].textContent;
+                self.renderForm(chirdren_id);
+            });
+        },
+        // Remover <Modal></Modal>
+        removeModal: function (e) {
+            $('.expired-account-modal').remove()
+            $('.modal-backdrop').remove()
+        },
+        // Llamar form
+        renderForm: function(id){
+            var self= this;
+
+            id = parseInt(id)
+
+            // if (!id) return
+
             this.do_action({
-                name:"Listado de clientes con deudas atrasadas",
-                type: 'ir.actions.act_window',
-                res_model: "res.partner",
-                views: [[false, 'list']],
-                target: 'new',
-                domain: [['unreconciled_aml_ids', 'in', move_id]],
-                context: {},
+                // name : "factura",
+                type : "ir.actions.act_window",
+                res_model : "account.invoice",
+                views : [[self.modelId[1], 'form']],
+                target : 'current',
+                domain : [['id', '=', id]],
+                context : {},
+                res_id : id,
+            }).then(function(){
+                self.removeModal();
             });
         }
     });

+ 90 - 14
static/src/js/widgets/expired_account_counters_now.js

@@ -2,6 +2,7 @@ function expired_account_counters_now (widget) {
     "use strict";
 
     var model = openerp;
+    var Qweb = openerp.web.qweb;
 
     widget.ExpiredAccountCountersNowWidget = widget.Base.extend({
         template: 'ExpiredAccountCountersNow',
@@ -9,6 +10,8 @@ function expired_account_counters_now (widget) {
         moveLine : [],
         resCompany : [],
         resCompany :[],
+        modelId:[],
+
         events: {
             'click a': 'showCustomers',
             'click h2': 'showCustomers',
@@ -45,10 +48,25 @@ function expired_account_counters_now (widget) {
                 self.resCompany=resCompany;
                 return self.fetchResCurrecy(resCompany);
             }).then(function(resCurrecy){
-                self.resCompany= resCurrecy;
+                self.resCurrecy= resCurrecy;
+                return self.fetchGetModelId();
+            }).then(function(modelId){
+                self.modelId = modelId;
                 return self.fetchReduceMoveLine();
             });
         },
+        // getModelId
+        fetchGetModelId: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var irModelData = new model.web.Model('ir.model.data');
+            var getObtjectReference = irModelData.get_func('get_object_reference');
+
+            this.alive(getObtjectReference('account', 'invoice_form')).then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Partner
         fetchPartner: function () {
             var self = this;
@@ -71,7 +89,7 @@ function expired_account_counters_now (widget) {
             var move_id = _.flatten(_.map(partner, function (map) {
                 return map.unreconciled_aml_ids
             }));
-            var field = ['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity'];
+            var field = ['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity', 'invoice','ref'];
             var domain = [['credit', '<=', 0], ['id', 'in', move_id], ['date_maturity', '=', hoy]];
             var moveLine = new model.web.Model('account.move.line');
 
@@ -115,7 +133,7 @@ function expired_account_counters_now (widget) {
         fetchReduceMoveLine: function () {
             var self = this;
             var residual =0;
-            var moneda =self.resCompany.shift();
+            var moneda =self.resCurrecy.shift();
             var company = _.map(self.resCompany, function(map){
                 return map.currency_id[1];
             });
@@ -141,18 +159,76 @@ function expired_account_counters_now (widget) {
         },
         showCustomers: function (e) {
             var self = this;
-            var hoy =moment().format('YYYY-MM-DD');
-            var move_id = _.flatten(_.map(self.moveLine, function (map) {
-                return map.id;
-            }));
+            if (self.moveLine.length <= 0)
+                return
+
+            var moneda = self.resCurrecy.shift();
+            var newmoveLine=[];
+            newmoveLine = self.moveLine;
+            var titleData=[
+                {
+                    title:"Deudas con vencimiento en el día de hoy"
+                }
+            ];
+            var headerModal=[
+                {
+                    title:"Cliente"
+                },
+                {
+                    title:"Numero de Factura"
+                },
+                {
+                    title:"Vencimiento"
+                },
+                {
+                    title:"Monto "
+                }
+            ];
+
+            var modal = Qweb.render('ExpiredAccountCountersModal', {
+                data : newmoveLine,
+                dataThead : headerModal,
+                modalTitle :titleData
+            });
+
+            $('.openerp_webclient_container').after(modal);
+            $('.expired-account-modal').modal()
+            $('.expired-account-modal').on('hidden.bs.modal', function (e) {
+                self.removeModal(e);
+            })
+
+            var contenido = $('.expired-account-modal').find('.table-tbody');
+            contenido.click(function (e) {
+                $(contenido).find('tr').removeClass('table-row-select');
+                $(e.target).closest('tr').addClass('table-row-select');
+                var chirdren_id =$(e.target).closest('tr').children()[0].textContent;
+                self.renderForm(chirdren_id);
+            });
+        },
+        // Remover <Modal></Modal>
+        removeModal: function (e) {
+            $('.expired-account-modal').remove()
+            $('.modal-backdrop').remove()
+        },
+        // Llamar form
+        renderForm: function(id){
+            var self= this;
+
+            id = parseInt(id)
+
+            // if (!id) return
+
             this.do_action({
-                name:"Listado de clientes por cobrar hoy",
-                type: 'ir.actions.act_window',
-                res_model: "res.partner",
-                views: [[false, 'list']],
-                target: 'new',
-                domain: [['unreconciled_aml_ids', 'in', move_id]],
-                context: {},
+                // name : "factura",
+                type : "ir.actions.act_window",
+                res_model : "account.invoice",
+                views : [[self.modelId[1], 'form']],
+                target : 'current',
+                domain : [['id', '=', id]],
+                context : {},
+                res_id : id,
+            }).then(function(){
+                self.removeModal();
             });
         }
     });

+ 23 - 4
static/src/js/widgets/invoice_today_counters.js

@@ -5,6 +5,9 @@ function invoice_today_counters (widget) {
 
     widget.InvoiceTodayCountersWidget = widget.Base.extend({
         template: 'InvoiceTodayCounters',
+        irModelData:[],
+        accountInvoice:[],
+
         events: {
             'click a': 'showCustomers',
             'click h2': 'showCustomers',
@@ -31,8 +34,24 @@ function invoice_today_counters (widget) {
             self.fetchAccountInvoice().then(function (accountInvoice) {
                 return accountInvoice;
             }).then(function (accountInvoice) {
-                return self.fetchReduceInvoice(accountInvoice);
+                self.accountInvoice=accountInvoice;
+                return self.fetchGetModelId();
+            }).then(function(irModelData){
+                self.irModelData=irModelData;
+                return self.fetchReduceInvoice(self.accountInvoice);
+            });
+        },
+        // getModelId
+        fetchGetModelId: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var irModelData = new model.web.Model('ir.model.data');
+            var getObtjectReference = irModelData.get_func('get_object_reference');
+
+            getObtjectReference('account', 'invoice_form').then(function(results){
+                defer.resolve(results);
             });
+            return defer;
         },
         // Invoice
         fetchAccountInvoice: function() {
@@ -64,6 +83,7 @@ function invoice_today_counters (widget) {
             self.$el.find('#morosidad').unblock();
         },
         showCustomers: function (e) {
+            var self= this;
             var hoy =moment().format('YYYY-MM-DD');
 
 
@@ -71,11 +91,10 @@ function invoice_today_counters (widget) {
                 name:"Facturas realizadas hoy",
                 type: 'ir.actions.act_window',
                 res_model: "account.invoice",
-                views: [[false, 'list'],[false,'form']],
-                target: 'new',
+                views: [[false, 'list'],[self.irModelData[1],'form']],
+                target: 'current',
                 domain: [['type', '=', 'out_invoice'], ['state', 'in', ['open','paid']], ['date_invoice', '=', hoy]],
                 context: {},
-                flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
             });
         }
     });

+ 20 - 3
static/src/js/widgets/missing_product.js

@@ -7,6 +7,8 @@ function missing_product (widget) {
         template: 'MissingProduct',
         stockQuant:[],
         productProduct:[],
+        modelId:[],
+
         events: {
             'click a': 'showCustomers',
             'click h2': 'showCustomers',
@@ -35,9 +37,24 @@ function missing_product (widget) {
                 return productProduct;
             }).then(function(productProduct){
                 self.productProduct = productProduct;
+                return self.fetchGetModelId();
+            }).then(function(modelId){
+                self.modelId = modelId;
                 return self.fetchReduceProduct();
             });
         },
+        // getModelId
+        fetchGetModelId: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var irModelData = new model.web.Model('ir.model.data');
+            var getObtjectReference = irModelData.get_func('get_object_reference');
+
+            this.alive(getObtjectReference('product', 'product_normal_form_view')).then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         fetchProductProduct : function(stockQaunt){
             var self = this;
             var defer =$.Deferred();
@@ -70,15 +87,15 @@ function missing_product (widget) {
             self.$el.find('#morosidad').unblock();
         },
         showCustomers: function (e) {
+            var self = this;
             this.do_action({
                 name:"Listado de productos faltan-tes",
                 type: 'ir.actions.act_window',
                 res_model: "product.product",
-                views: [[false, 'list'],[false,'form']],
-                target: 'new',
+                views: [[false, 'list'],[self.modelId[1],'form']],
+                target: 'current',
                 domain: [['type', '=', 'product'],['qty_available','<=',0]],
                 context: {},
-                flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
             });
         }
     });

+ 18 - 3
static/src/js/widgets/ranking_sales_partner.js

@@ -8,6 +8,7 @@ function ranking_sales_partner (widget) {
         data : [],
         accountInvoice : [],
         resPartner : [],
+        modelId:[],
 
         events: {
             'click canvas': 'showCustomers'
@@ -38,9 +39,24 @@ function ranking_sales_partner (widget) {
                 return self.fecthPartner(accountInvoice);
             }).then(function (resPartner) {
                 self.resPartner = resPartner;
+                return self.fetchGetModelId();
+            }).then(function(modelId){
+                self.modelId = modelId;
                 return self.fetchProductRanking();
             });
         },
+        // getModelId
+        fetchGetModelId: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var irModelData = new model.web.Model('ir.model.data');
+            var getObtjectReference = irModelData.get_func('get_object_reference');
+
+            this.alive(getObtjectReference('base', 'view_partner_form')).then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Obtener factura
         fecthInvoice: function(){
             var self = this;
@@ -167,11 +183,10 @@ function ranking_sales_partner (widget) {
                 name:"Listado de clientes con más compras",
                 type: 'ir.actions.act_window',
                 res_model: "res.partner",
-                views: [[false,'list'],[false,'form']],
-                target: 'new',
+                views: [[false,'list'],[self.modelId[1],'form']],
+                target: 'current',
                 domain: [['id', 'in', partner_id]],
                 context: {},
-                flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
             });
         }
     });

+ 19 - 3
static/src/js/widgets/ranking_sales_product.js

@@ -10,6 +10,7 @@ function ranking_sales_product (widget) {
         invoiceLine : [],
         productProduct : [],
         ranking:[],
+        modelId:[],
 
         events: {
             'click canvas': 'showCustomers'
@@ -43,9 +44,25 @@ function ranking_sales_product (widget) {
                 return self.fecthProductProduct(invoiceLine);
             }).then(function(productProduct){
                 self.productProduct = productProduct;
+                return self.fetchGetModelId();
+            }).then(function(modelId){
+                self.modelId=modelId;
                 return self.fetchProductRanking();
             });
         },
+        // getModelId
+        fetchGetModelId: function(){
+            var self = this;
+            var defer = $.Deferred();
+            var irModelData = new model.web.Model('ir.model.data');
+            var getObtjectReference = irModelData.get_func('get_object_reference');
+
+
+            this.alive(getObtjectReference('product', 'product_normal_form_view')).then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
         // Obtener factura
         fecthInvoice: function(){
             var self = this;
@@ -200,11 +217,10 @@ function ranking_sales_product (widget) {
                 name:"Listado de productos más vendidos",
                 type: 'ir.actions.act_window',
                 res_model: "product.product",
-                views: [[false, 'list'],[false,'form']],
-                target: 'new',
+                views: [[false, 'list'],[self.modelId[1],'form']],
+                target: 'current',
                 domain: [['id', 'in', product_id],['type','=', 'product']],
                 context: {},
-                flags: {'form': {'action_buttons': false, 'options': {'mode': 'view'}}},
             });
         }
     });

+ 29 - 0
static/src/lib/jquery.timeago.es.js

@@ -0,0 +1,29 @@
+(function (factory) {
+  if (typeof define === 'function' && define.amd) {
+    define(['jquery'], factory);
+  } else if (typeof module === 'object' && typeof module.exports === 'object') {
+    factory(require('jquery'));
+  } else {
+    factory(jQuery);
+  }
+}(function (jQuery) {
+  // Spanish
+  jQuery.timeago.settings.strings = {
+     prefixAgo: "hace",
+     prefixFromNow: "dentro de",
+     suffixAgo: "",
+     suffixFromNow: "",
+     seconds: "menos de un minuto",
+     minute: "un minuto",
+     minutes: "unos %d minutos",
+     hour: "una hora",
+     hours: "%d horas",
+     day: "un día",
+     days: "%d días",
+     month: "un mes",
+     months: "%d meses",
+     year: "un año",
+     years: "%d años"
+  };
+}));
+

+ 51 - 0
static/src/xml/widgets/eiru_dashboard_modal.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="ExpiredAccountCountersModal">
+        <div class="modal fade expired-account-modal" tabindex="-1" role="dialog">
+            <div class="modal-dialog modal-lg" role="document">
+                <div class="modal-content openerp">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" aria-hidden="true">x</button>
+                        <h3 class="modal-title" t-foreach="modalTitle" t-as="title">
+                            <t t-esc="title_value.title"/>
+                        </h3>
+                    </div>
+                    <div class="oe_view_manager_body">
+                        <table class="oe_list_content">
+                            <thead >
+                                <tr class="oe_list_header_columns" >
+                                    <th t-foreach="dataThead" t-as="head" class="oe_list_header_char oe_sortable">
+                                        <t t-esc="head_value.title"/>
+                                    </th>
+                                </tr>
+                            </thead>
+                            <tbody class="table-tbody">
+                                <tr t-foreach="data" t-as="field">
+                                    <td><t t-esc="field_value.invoice[0]"/></td>
+                                    <td><t t-esc="field_value.partner_id[1]"/></td>
+                                    <td><t t-esc="field_value.ref"/></td>
+
+                                    <td>
+                                        <t t-set="vencimiento" t-value="field_value.date_maturity"/>
+                                        <t t-js="ctx">
+                                            ctx.vencimiento = $.timeago(moment(ctx.vencimiento).format("YYYY-DD-MM"));
+                                        </t>
+                                        <t t-esc="vencimiento"/></td>
+                                    <td>
+                                        <t t-js="ctx">
+                                            ctx.field.amount_residual = accounting.formatNumber(ctx.field.amount_residual,0,',','.');
+                                        </t>
+                                        <t t-esc="field_value.amount_residual"/>
+                                    </td>
+                                </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </t>
+</template>

+ 1 - 0
static/src/xml/widgets/expired_account_counters.xml

@@ -19,5 +19,6 @@
                 </div>
             </div>
         </div>
+
     </t>
 </template>

+ 2 - 0
templates.xml

@@ -10,6 +10,8 @@
 
                 <!-- Dashboard Widget Base -->
                 <script type="text/javascript" src="/eiru_dashboard/static/src/js/widget_base.js" />
+                <!-- LIB -->
+                <script type="text/javascript" src="/eiru_dashboard/static/src/lib/jquery.timeago.es.js" />
 
                 <!-- Dashboard Widgets -->
                 <script type="text/javascript" src="/eiru_dashboard/static/src/js/widgets/ranking_sales_product.js" />