|
@@ -8,6 +8,7 @@ openerp.product_product_utility = function (instance, local) {
|
|
lineInvoice:[],
|
|
lineInvoice:[],
|
|
currencyRate:[],
|
|
currencyRate:[],
|
|
resCompany:[],
|
|
resCompany:[],
|
|
|
|
+ resCurrency:[],
|
|
|
|
|
|
init: function (parent) {
|
|
init: function (parent) {
|
|
this._super(parent);
|
|
this._super(parent);
|
|
@@ -36,6 +37,9 @@ openerp.product_product_utility = function (instance, local) {
|
|
return self.fetchResCompany();
|
|
return self.fetchResCompany();
|
|
}).then(function(resCompany){
|
|
}).then(function(resCompany){
|
|
self.resCompany = resCompany;
|
|
self.resCompany = resCompany;
|
|
|
|
+ return self.fetchResCurrecy(resCompany);
|
|
|
|
+ }).then(function (resCurrency){
|
|
|
|
+ self.resCurrency = resCurrency;
|
|
return self.fetchFilterInvoice();
|
|
return self.fetchFilterInvoice();
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -99,6 +103,24 @@ openerp.product_product_utility = function (instance, local) {
|
|
});
|
|
});
|
|
return defer;
|
|
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
|
|
// Separa Invoice
|
|
fetchFilterInvoice(){
|
|
fetchFilterInvoice(){
|
|
@@ -108,6 +130,7 @@ openerp.product_product_utility = function (instance, local) {
|
|
var linepurchase;
|
|
var linepurchase;
|
|
var linesale;
|
|
var linesale;
|
|
var company;
|
|
var company;
|
|
|
|
+ var moneda = self.resCurrency.shift();
|
|
|
|
|
|
company = _.map(self.resCompany, function(map){
|
|
company = _.map(self.resCompany, function(map){
|
|
return map.currency_id[1];
|
|
return map.currency_id[1];
|
|
@@ -137,13 +160,21 @@ openerp.product_product_utility = function (instance, local) {
|
|
|
|
|
|
var venta = linesale.total / linesale.qty;
|
|
var venta = linesale.total / linesale.qty;
|
|
var compra = linepurchase.total / linepurchase.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
|
|
//Get Invoice
|