فهرست منبع

[FIX] widget deuda atrasadas Correcion en el selecion de los move line

adrielso 7 سال پیش
والد
کامیت
bd1ce334a7
1فایلهای تغییر یافته به همراه57 افزوده شده و 57 حذف شده
  1. 57 57
      static/src/js/widgets/expired_account_counters.js

+ 57 - 57
static/src/js/widgets/expired_account_counters.js

@@ -5,12 +5,12 @@ function expired_account_counters (widget) {
     var Qweb = openerp.web.qweb;
 
     widget.ExpiredAccountCountersWidget = widget.Base.extend({
-        template : 'ExpiredAccountCounters',
-        moveLine : [],
-        resCompany : [],
-        resCurrecy : [],
-        modelId : [],
-        accountInvoice : [],
+        template: 'ExpiredAccountCounters',
+        moveLine: [],
+        resCompany: [],
+        resCurrecy: [],
+        modelId: [],
+        accountInvoice: [],
 
         events: {
             'click a': 'showCustomers',
@@ -19,7 +19,7 @@ function expired_account_counters (widget) {
 
         init: function (parent) {
             this._super(parent, {
-                width : 3,
+                width: 3,
                 height: 2
             });
         },
@@ -29,7 +29,7 @@ function expired_account_counters (widget) {
             self.fetchInitial();
         },
         // Consulta Inicial
-        fetchInitial: function(){
+        fetchInitial: function() {
             var self = this;
             self.$el.find('.grid-stack-item-content dashboard').block({
                 message: null,
@@ -40,55 +40,57 @@ function expired_account_counters (widget) {
 
             self.$el.find('.widget-content.widget-loading').css('display','flex');
 
-            self.fetchMoveLine().then(function (moveLine){
+            self.fetchMoveLine().then(function (moveLine) {
                 return moveLine;
-            }).then(function (moveLine){
-                self.moveLine = moveLine;
+            }).then(function (moveLine) {
+                self.moveLine = _.filter(moveLine, function(item) {
+                    return item.amount_residual > 0;
+                });
                 return self.fetchInvoice(moveLine);
-            }).then(function(accountInvoice){
+            }).then(function(accountInvoice) {
                 self.accountInvoice = accountInvoice;
                 return self.fetchResCompany();
-            }).then(function (resCompany){
+            }).then(function (resCompany) {
                 self.resCompany = resCompany;
                 return self.fetchResCurrecy();
-            }).then(function (resCurrecy){
+            }).then(function (resCurrecy) {
                 self.resCurrecy = resCurrecy;
                 return self.fetchGetModelId();
-            }).then(function(modelId){
+            }).then(function(modelId) {
                 self.modelId= modelId;
                 return self.fetchReduceMoveLine();
             });
         },
         // getModelId
-        fetchGetModelId: function(){
+        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){
+            this.alive(getObtjectReference('account', 'invoice_form')).then(function(results) {
                 defer.resolve(results);
             });
 
             return defer;
         },
         // Move line
-        fetchMoveLine: function (){
+        fetchMoveLine: function () {
             var self = this;
-            var hoy =moment().format('YYYY-MM-DD');
+            var hoy = moment().format('YYYY-MM-DD');
             var defer = $.Deferred();
-            var field =['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity', 'invoice', 'ref', 'invoice', 'amount_residual_currency'];
-            var domain=[['credit', '<=', 0],['date_maturity', '<', hoy]];
+            var field = ['id', 'partner_id', 'amount_residual', 'credit', 'debit', 'date_maturity', 'invoice', 'ref', 'invoice', 'amount_residual_currency','state'];
+            var domain = [['credit', '<=', 0], ['date_maturity', '<', hoy]];
             var moveLine = new model.web.Model('account.move.line');
 
-            moveLine.query(field).filter(domain).all().then(function(results){
+            moveLine.query(field).filter(domain).all().then(function(results) {
                 defer.resolve(results);
             });
 
             return defer;
         },
         // invoice
-        fetchInvoice: function(moveline){
+        fetchInvoice: function(moveline) {
             var self = this ;
             var defer = $.Deferred()
             var ref = _.map(moveline, function(map) {
@@ -104,11 +106,11 @@ function expired_account_counters (widget) {
             return defer;
         },
         //Comapnia
-        fetchResCompany: function(){
+        fetchResCompany: function() {
             var self = this;
             var defer = $.Deferred();
-            var fields =['id','name', 'currency_id', 'logo'];
-            var domain =[['id', '=', 1]];
+            var fields = ['id','name', 'currency_id', 'logo'];
+            var domain = [['id', '=', 1]];
             var resCompanyIds = new model.web.Model('res.company');
 
             resCompanyIds.query(fields).filter(domain).all().then(function (results) {
@@ -118,14 +120,14 @@ function expired_account_counters (widget) {
             return defer;
         },
         // Res currecy
-        fetchResCurrecy : function(){
+        fetchResCurrecy : function() {
             var self = this;
             var defer = $.Deferred();
-            var fields =['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
-            var domain =[['active','=', true]];
+            var fields = ['id','name', 'symbol', 'rate_silent', 'base', 'decimal_separator', 'decimal_places', 'thousands_separator', 'symbol_position'];
+            var domain = [['active','=', true]];
             var resCurrecy = new model.web.Model('res.currency');
 
-            resCurrecy.query(fields).filter(domain).all().then(function(results){
+            resCurrecy.query(fields).filter(domain).all().then(function(results) {
                 defer.resolve(results);
             });
 
@@ -139,7 +141,7 @@ function expired_account_counters (widget) {
             });
         },
         // Moneda de la factura
-        getInvoiceCurrency: function(id){
+        getInvoiceCurrency: function(id) {
             var self = this;
             var  currency_invoice = _.filter(self.accountInvoice, function(filter) {
                 return filter.id === id;
@@ -151,7 +153,7 @@ function expired_account_counters (widget) {
             var self = this;
             var newmoveLine = [];
             var inteMove;
-            var residual =0;
+            var residual = 0;
             var currencyInvoice;
             var company = self.resCompany.shift();
             var currencyBase = self.getCurrency(company.currency_id[0]).shift();
@@ -161,18 +163,18 @@ function expired_account_counters (widget) {
 
                 currencyInvoice = self.getInvoiceCurrency(inteMove.invoice[0]).shift();
 
-                if(!currencyInvoice){
+                if(!currencyInvoice) {
                     currencyInvoice = {};
                     currencyInvoice.rate=currencyBase.rate_silent;
                 }
 
                 newmoveLine.push({
-                    amount_residual : inteMove.amount_residual,
-                    amount_residual_currency :(inteMove.amount_residual_currency * (currencyBase.rate_silent / currencyInvoice.rate_silent))
+                    amount_residual: inteMove.amount_residual,
+                    amount_residual_currency: (inteMove.amount_residual_currency * (currencyBase.rate_silent / currencyInvoice.rate_silent))
                 });
             }
 
-            if (newmoveLine.length > 0){
+            if (newmoveLine.length > 0) {
                 residual = _.reduce(_.map(newmoveLine, function (map) {
                     return map.amount_residual_currency;
                 }), function (memo, num) {
@@ -192,36 +194,35 @@ function expired_account_counters (widget) {
                 return
             }
 
-
             var moneda = self.resCurrecy.shift();
             var newmoveLine = self.moveLine;
-            var titleData=[
+            var titleData = [
                 {
-                    title:"Deudas atrasadas"
+                    title: "Deudas atrasadas"
                 }
             ];
             var headerModal = [
                 {
-                    title:"id"
+                    title: "id"
                 },
                 {
-                    title:"Cliente"
+                    title: "Cliente"
                 },
                 {
-                    title:"Numero de Factura"
+                    title: "Numero de Factura"
                 },
                 {
-                    title:"Vencimiento"
+                    title: "Vencimiento"
                 },
                 {
-                    title:"Monto "
+                    title: "Monto "
                 }
             ];
 
             var modal = Qweb.render('ExpiredAccountCountersModal', {
-                data : newmoveLine,
-                dataThead : headerModal,
-                modalTitle : titleData
+                data: newmoveLine,
+                dataThead: headerModal,
+                modalTitle: titleData
             });
 
             $('.openerp_webclient_container').after(modal);
@@ -245,19 +246,18 @@ function expired_account_counters (widget) {
         },
         // Llamar form
         renderForm: function(id){
-            var self= this;
+            var self = this;
             id = parseInt(id);
 
             this.do_action({
-
-                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(){
+                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();
             });
         }