From d3278379c8d7cb0efe66dfb7ae934d74b7b40e42 Mon Sep 17 00:00:00 2001 From: AjmalCybro Date: Wed, 5 Apr 2023 14:22:15 +0530 Subject: [PATCH] Apr 5 : [UPDT] Updated 'dashboard_pos' --- dashboard_pos/__manifest__.py | 2 +- dashboard_pos/models/pos_dashboard.py | 6 +++--- dashboard_pos/static/src/js/pos_dashboard.js | 6 +----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/dashboard_pos/__manifest__.py b/dashboard_pos/__manifest__.py index 5f1442455..8ad937609 100644 --- a/dashboard_pos/__manifest__.py +++ b/dashboard_pos/__manifest__.py @@ -21,7 +21,7 @@ ################################################################################### { 'name': "POS Dashboard", - 'version': '16.0.1.0.1', + 'version': '16.0.1.0.2', 'summary': """POS Dashboard""", 'description': """POS Dashboard""", 'category': 'Point of Sale', diff --git a/dashboard_pos/models/pos_dashboard.py b/dashboard_pos/models/pos_dashboard.py index a21e41771..dd102aa67 100644 --- a/dashboard_pos/models/pos_dashboard.py +++ b/dashboard_pos/models/pos_dashboard.py @@ -22,6 +22,7 @@ import pytz from odoo import models, fields, api from datetime import timedelta, datetime, date +import json class PosDashboard(models.Model): @@ -67,7 +68,7 @@ class PosDashboard(models.Model): company_id = self.env.company.id cr = self._cr cr.execute( - """select pos_payment_method.name,sum(amount) from pos_payment inner join pos_payment_method on + """select pos_payment_method.name ->>'en_US',sum(amount) from pos_payment inner join pos_payment_method on pos_payment_method.id=pos_payment.payment_method_id group by pos_payment_method.name ORDER BY sum(amount) DESC; """) payment_details = cr.fetchall() @@ -194,7 +195,7 @@ class PosDashboard(models.Model): def get_the_top_products(self): company_id = self.env.company.id - query = '''select DISTINCT(product_template.name) as product_name,sum(qty) as total_quantity from + query = '''select DISTINCT(product_template.name)->>'en_US' as product_name,sum(qty) as total_quantity from pos_order_line inner join product_product on product_product.id=pos_order_line.product_id inner join product_template on product_product.product_tmpl_id = product_template.id where pos_order_line.company_id = ''' + str( company_id) + ''' group by product_template.id ORDER @@ -202,7 +203,6 @@ class PosDashboard(models.Model): self._cr.execute(query) top_product = self._cr.dictfetchall() - total_quantity = [] for record in top_product: total_quantity.append(record.get('total_quantity')) diff --git a/dashboard_pos/static/src/js/pos_dashboard.js b/dashboard_pos/static/src/js/pos_dashboard.js index 6ff95daf4..69f302d7b 100644 --- a/dashboard_pos/static/src/js/pos_dashboard.js +++ b/dashboard_pos/static/src/js/pos_dashboard.js @@ -5,10 +5,7 @@ var AbstractAction = require('web.AbstractAction'); var core = require('web.core'); const { loadBundle } = require("@web/core/assets"); var ajax = require('web.ajax'); -//var field_utils = require('web.field_utils'); -//var pyUtils = require('web.py_utils'); var session = require('web.session'); -//var time = require('web.time'); var web_client = require('web.web_client'); var rpc = require('web.rpc'); var _t = core._t; @@ -397,9 +394,8 @@ var PosDashboard = AbstractAction.extend({ model: "pos.order", method: "get_the_top_products", }).then(function (arrays) { - - var data = { + labels: arrays[1], datasets: [ {