Ver Fonte

[FIX] ajustes varios

Rodney Elpidio Enciso Arias há 6 anos atrás
pai
commit
9bf04d0edb

+ 3 - 3
controller/helpers/account_invoice.py

@@ -12,11 +12,11 @@ def get_account_invoice_sale_type():
         	invoice.origin,
         	invoice.partner_id,
         	invoice.user_id,
-        	invoice.amount_total * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]) as invoice_rate,
+        	invoice.amount_total * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
             invoice.number,
             partner.name,
             customer.name,
-            invoice.amount_tax,
+            invoice.amount_tax * (%s / (array_agg(rate.rate ORDER BY rate.id DESC))[1]),
             invoice.state,
             journal.store_id,
             invoice.journal_id,
@@ -57,7 +57,7 @@ def get_account_invoice_sale_type():
             invoice.company_id
     '''
 
-    r.cr.execute(query,(tuple([company_currency_rate])))
+    r.cr.execute(query,(tuple([company_currency_rate,company_currency_rate])))
 
     return [
         {

BIN
controller/helpers/account_invoice.pyc


+ 10 - 2
controller/helpers/product_product.py

@@ -35,7 +35,8 @@ def get_product_product():
             template.company_id,
             template.store_id,
             template.type,
-            product.ean13
+            product.ean13,
+            (array_agg(history.cost ORDER BY history.id DESC))[1] AS standard_price
         FROM product_product AS product
         LEFT JOIN product_template AS template
         ON template.id = product.product_tmpl_id
@@ -47,6 +48,8 @@ def get_product_product():
         ON attr.id = attr_value.attribute_id
         LEFT JOIN product_brand AS brand
         ON brand.id = template.product_brand_id
+        LEFT JOIN product_price_history AS history
+        ON history.product_template_id = product.product_tmpl_id
         GROUP BY
         	product.id,
         	template.categ_id,
@@ -80,7 +83,8 @@ def get_product_product():
             template.company_id,
             template.store_id,
             template.type,
-            product.ean13
+            product.ean13,
+            (array_agg(history.cost ORDER BY history.id DESC))[1] AS standard_price
         FROM product_product AS product
         LEFT JOIN product_template AS template
         ON template.id = product.product_tmpl_id
@@ -90,6 +94,8 @@ def get_product_product():
         ON attr_value.id = attr_rel.att_id
         LEFT JOIN product_attribute AS attr
         ON attr.id = attr_value.attribute_id
+        LEFT JOIN product_price_history AS history
+        ON history.product_template_id = product.product_tmpl_id
         GROUP BY
         	product.id,
         	template.categ_id,
@@ -127,6 +133,7 @@ def get_product_product():
                 'store_id': j[14],
                 'type': j[15],
                 'ean13': j[16],
+                'standard_price': j[17],
             } for j in r.cr.fetchall()
         ]
     else:
@@ -148,5 +155,6 @@ def get_product_product():
                 'store_id': j[12],
                 'type': j[13],
                 'ean13': j[14],
+                'standard_price': j[15],
             } for j in r.cr.fetchall()
         ]

BIN
controller/helpers/product_product.pyc


+ 0 - 102
static/src/js/configuration_reporting.js

@@ -1,102 +0,0 @@
-function configuration_reporting (reporting, instance, widget) {
-    "use strict";
-    var widgets = widget;
-
-    widget.ReportingWidget = instance.Widget.extend({
-        template: 'EiruReport',
-        events: {},
-
-        start: function () {
-            var self = this;
-            self.fetchInitial();
-            self.BuildChart();
-        },
-
-        fetchInitial:function() {
-            var self = this;
-            self.fetchResUser().then(function (ResUser) {
-                return ResUser;
-            }).then(function (ResUser) {
-                self.ResUser = ResUser;
-                return self.fetchResCurrency();
-            }).then(function (ResCurrency) {
-                self.ResCurrency = ResCurrency;
-                self.BuildChart();
-                return self.InsertUser();
-            });
-        },
-
-        fetchResUser: function() {
-            var self = this;
-            var defer = $.Deferred();
-            var fields = ['id','name'];
-            var domain = [['id','=',self.session.uid]];
-            var ResUser = new instance.web.Model('res.users');
-            ResUser.query(fields).filter(domain).all().then(function (results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        /*====================================================================
-            RES CURRENCY
-        ====================================================================*/
-        fetchResCurrency : 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 = [
-                ['base','=',true],
-            ];
-            var ResCurrency = new instance.web.Model('res.currency');
-            ResCurrency.query(fields).filter(domain).all().then(function(results) {
-                defer.resolve(results);
-            });
-            return defer;
-        },
-
-        BuildChart: function(){
-            var self = this;
-            var label = [
-                'Enero',
-                'Febrero',
-                'Marzo',
-                'Abril',
-                'Mayo',
-                'Junio',
-                'Julio',
-                'Agosto',
-                'Septiembre',
-                'Octubre',
-                'Noviembre',
-                'Diciembre',
-            ];
-            var body = [
-                '20000',
-                '30000',
-                '80000',
-                '50000',
-                '60000',
-                '70000',
-                '90000',
-                '40000',
-                '100000',
-                '70000',
-                '30000',
-                '50000',
-            ];
-            var CurrencyBase = self.ResCurrency;
-            if(CurrencyBase){
-                var chart = new reporting.ReportChartWidget(self);
-                chart.BuildDemoChart(label,body,CurrencyBase[0]);
-            }
-        },
-
-        InsertUser: function(id) {
-            var self = this;
-            var user = self.ResUser[0].name;
-            self.$el.find('.user-content').find('p').text("Hola " + user + " ...!");
-        },
-
-    });
-}

+ 0 - 1
static/src/js/main.js

@@ -4,7 +4,6 @@ openerp.eiru_reports_sales = function (instance) {
     var reporting = instance.eiru_reports_sales;
 
     reporting_base(instance,reporting);
-    configuration_reporting(reporting,instance,reporting);
 
     try {
         /*

+ 26 - 6
static/src/js/reports/report_product_list.js

@@ -138,9 +138,6 @@ function report_product_list(reporting){
                     var sale = _.filter(ProductPriceList,function (item) {
                         return item.type == 'sale';
                     });
-                    var purchase = _.filter(ProductPriceList,function (item) {
-                        return item.type == 'purchase';
-                    });
                     self.$el.find('#current-sale-price').append('<option value="9999999">Precio Base</option>');
                     _.each(sale,function(item){
                         self.$el.find('#current-sale-price').append('<option value="' + item.id + '">' + item.name + '</option>');
@@ -242,7 +239,20 @@ function report_product_list(reporting){
         fetchPricelistVersionItem: function() {
             var self = this;
             var defer = $.Deferred();
-            var fields = ['name','product_id','categ_id','min_quantity','product_tmpl_id','sequence','base','price_discount','price_surcharge','price_round','price_min_margin','price_max_margin'];
+            var fields = [
+                'name',
+                'product_id',
+                'categ_id',
+                'min_quantity',
+                'product_tmpl_id',
+                'sequence',
+                'base',
+                'price_discount',
+                'price_surcharge',
+                'price_round',
+                'price_min_margin',
+                'price_max_margin'
+            ];
             var ResUser = new model.web.Model('product.pricelist.item');
             ResUser.query(fields).filter().all().then(function (results) {
                 defer.resolve(results);
@@ -464,11 +474,21 @@ function report_product_list(reporting){
                 if(CurrencyBase.id == priceList[0].currency_id.id){
                     return product.list_price*(1+x[0].price_discount)+x[0].price_surcharge;
                 }else{
+                    var price = 0;
                     if(CurrencyBase.rate_silent > priceList[0].currency_id.rate_silent){
-                        return (product.list_price / (CurrencyBase.rate_silent / priceList[0].currency_id.rate_silent))*(1+x[0].price_discount)+x[0].price_surcharge;
+                        if(x[0].base == 1){
+                            price = (product.list_price / (CurrencyBase.rate_silent / priceList[0].currency_id.rate_silent))*(1+x[0].price_discount)+x[0].price_surcharge;
+                        }else{
+                            price = (product.standard_price / (CurrencyBase.rate_silent / priceList[0].currency_id.rate_silent))*(1+x[0].price_discount)+x[0].price_surcharge;
+                        }
                     }else{
-                        return (product.list_price * (CurrencyBase.rate_silent / priceList[0].currency_id.rate_silent))*(1+x[0].price_discount)+x[0].price_surcharge;
+                        if(x[0].base == 1){
+                            price = (product.list_price * (priceList[0].currency_id.rate_silent / CurrencyBase.rate_silent))*(1+x[0].price_discount)+x[0].price_surcharge;
+                        }else{
+                            price = (product.standard_price * (priceList[0].currency_id.rate_silent / CurrencyBase.rate_silent))*(1+x[0].price_discount)+x[0].price_surcharge;
+                        }
                     }
+                    return price;
                 }
             }else{
                 return product.list_price;

+ 1 - 1
templates.xml

@@ -9,7 +9,7 @@
                 <!-- configuration < main > -->
                 <script type="text/javascript" src="/eiru_reports_sales/static/src/js/main.js" />
                 <script type="text/javascript" src="/eiru_reports_sales/static/src/js/reporting_base.js" />
-                <script type="text/javascript" src="/eiru_reports_sales/static/src/js/configuration_reporting.js" />
+                <!-- <script type="text/javascript" src="/eiru_reports_sales/static/src/js/configuration_reporting.js" /> -->
                 <script type="text/javascript" src="/eiru_reports_sales/static/src/js/pdf.js" />
                 <script type="text/javascript" src="/eiru_reports_sales/static/src/js/chart.js" />
                 <script type="text/javascript" src="/eiru_reports_sales/static/src/js/datepicker.js" />