Explorar o código

[FIX] Adicionar el simbolo de la moneda al lado del monto, segun la moneda base del sistema

Adrielso %!s(int64=7) %!d(string=hai) anos
pai
achega
08d8dfd454
Modificáronse 1 ficheiros con 38 adicións e 7 borrados
  1. 38 7
      static/src/js/product_product_utility.js

+ 38 - 7
static/src/js/product_product_utility.js

@@ -8,6 +8,7 @@ openerp.product_product_utility = function (instance, local) {
         lineInvoice:[],
         currencyRate:[],
         resCompany:[],
+        resCurrency:[],
 
         init: function (parent) {
             this._super(parent);
@@ -36,6 +37,9 @@ openerp.product_product_utility = function (instance, local) {
                 return self.fetchResCompany();
             }).then(function(resCompany){
                 self.resCompany = resCompany;
+                return self.fetchResCurrecy(resCompany);
+            }).then(function (resCurrency){
+                self.resCurrency = resCurrency;
                 return self.fetchFilterInvoice();
             });
         },
@@ -99,6 +103,24 @@ openerp.product_product_utility = function (instance, local) {
             });
             return defer;
         },
+        // Moneda Segun la compania
+        fetchResCurrecy : function(company){
+            var self = this;
+            var defer = $.Deferred();
+
+            var id_curency = _.flatten(_.map(company,function(map){
+                return map.currency_id[0];
+            }));
+
+            var fields =['id','name', 'symbol'];
+            var domain =[['id','in',id_curency]];
+            var resCurrecy = new  instance.web.Model('res.currency');
+
+            resCurrecy.query(fields).filter(domain).all().then(function(results){
+                defer.resolve(results);
+            });
+            return defer;
+        },
 
         // Separa Invoice
         fetchFilterInvoice(){
@@ -108,6 +130,7 @@ openerp.product_product_utility = function (instance, local) {
             var linepurchase;
             var linesale;
             var company;
+            var moneda = self.resCurrency.shift();
 
             company = _.map(self.resCompany, function(map){
                 return map.currency_id[1];
@@ -137,13 +160,21 @@ openerp.product_product_utility = function (instance, local) {
 
             var venta = linesale.total / linesale.qty;
             var compra = linepurchase.total / linepurchase.qty;
-
-            self.$el.find('.product_utility-content.sale').find('a').text(accounting.formatNumber((venta),2, ".", ","));
-            self.$el.find('.product_utility-content.puchase').find('a').text(accounting.formatNumber((compra),2, ".", ","));
-            self.$el.find('.product_utility-content.utility').find('a').text(accounting.formatNumber((venta - compra),2, ".", ","));
-
-            self.$el.find('.product_utility-footer').find('span').text("Moneda Base "+company);
-
+            var utilidad = venta - compra;
+
+            if (moneda.id  !=  166){
+                venta = accounting.formatNumber((venta),2, ".", ",");
+                compra = accounting.formatNumber((compra),2, ".", ",");
+                utilidad = accounting.formatNumber((utilidad),2, ".", ",");
+            } else{
+                venta = accounting.formatNumber((venta),",",".");
+                compra = accounting.formatNumber((compra),",", ".");
+                utilidad = accounting.formatNumber((utilidad), ",",".");
+            }
+            self.$el.find('.product_utility-content.sale').find('a').text(venta).append(" <small>"+moneda.symbol+"</small>");
+            self.$el.find('.product_utility-content.puchase').find('a').text(compra).append(" <small>"+moneda.symbol+"</small>");
+            self.$el.find('.product_utility-content.utility').find('a').text(utilidad).append(" <small>"+moneda.symbol+"</small>");
+            // self.$el.find('.product_utility-footer').find('span').text("Moneda Base "+company);
         },
 
         //Get Invoice