From 4ff37c175e1726f8b6dc94e73703322182409c1a Mon Sep 17 00:00:00 2001 From: Raman Marikanti Date: Tue, 16 Dec 2025 16:05:55 +0530 Subject: [PATCH] dashboard weight updates --- .../dashboard/models/stock_dashboard.py | 27 ++++++++++--------- .../pqgrid_consumption_dashboard.js | 1 + .../pqgrid_dashboard/pqgrid_sale_dashboard.js | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/custom_addons/dashboard/models/stock_dashboard.py b/custom_addons/dashboard/models/stock_dashboard.py index 764bde9b2..d694c0f47 100644 --- a/custom_addons/dashboard/models/stock_dashboard.py +++ b/custom_addons/dashboard/models/stock_dashboard.py @@ -23,12 +23,12 @@ class SamashtiDashboard(models.AbstractModel): # Convert local datetime to UTC from_local = local_tz.localize(datetime.combine(from_date_obj, time.min)) to_local = local_tz.localize(datetime.combine(to_date_obj, time.max)) - from_utc = from_local.astimezone(pytz.UTC) - to_utc = to_local.astimezone(pytz.UTC) + # from_utc = from_local.astimezone(pytz.UTC) + # to_utc = to_local.astimezone(pytz.UTC) # Convert to string in Odoo datetime format - fromDate = "'"+str(fields.Datetime.to_string(from_utc))+"'" - toDate = "'"+str(fields.Datetime.to_string(to_utc))+"'" + fromDate = "'"+str(fields.Datetime.to_string(from_local))+"'" + toDate = "'"+str(fields.Datetime.to_string(to_local))+"'" sql = f""" SELECT @@ -159,12 +159,12 @@ class SamashtiDashboard(models.AbstractModel): # Convert local datetime to UTC from_local = local_tz.localize(datetime.combine(from_date_obj, time.min)) to_local = local_tz.localize(datetime.combine(to_date_obj, time.max)) - from_utc = from_local.astimezone(pytz.UTC) - to_utc = to_local.astimezone(pytz.UTC) + # from_utc = from_local.astimezone(pytz.UTC) + # to_utc = to_local.astimezone(pytz.UTC) # Convert to string in Odoo datetime format - from_datetime = fields.Datetime.to_string(from_utc) - to_datetime = fields.Datetime.to_string(to_utc) + from_datetime = fields.Datetime.to_string(from_local) + to_datetime = fields.Datetime.to_string(to_local) # Search for posted invoices within the date range invoice_ids = self.env['account.move'].search([ ('state', '=', 'posted'), @@ -195,7 +195,7 @@ class SamashtiDashboard(models.AbstractModel): customer = order_data['partner_id'][-1] if order_data['partner_id'] else "Unknown" quantity = sum(order.order_line.mapped('product_uom_qty')) - weight = f"{sum(order.order_line.mapped('bag_weight'))} kg" + weight = sum(order.order_line.mapped('bag_weight')) # Combine product tags product_tags = ', '.join( @@ -246,12 +246,12 @@ class SamashtiDashboard(models.AbstractModel): # Convert local datetime to UTC from_local = local_tz.localize(datetime.combine(from_date_obj, time.min)) to_local = local_tz.localize(datetime.combine(to_date_obj, time.max)) - from_utc = from_local.astimezone(pytz.UTC) - to_utc = to_local.astimezone(pytz.UTC) + # from_utc = from_local.astimezone(pytz.UTC) + # to_utc = to_local.astimezone(pytz.UTC) # Convert to string in Odoo datetime format - fromDate = "'"+str(fields.Datetime.to_string(from_utc))+"'" - toDate = "'"+str(fields.Datetime.to_string(to_utc))+"'" + fromDate = "'"+str(fields.Datetime.to_string(from_local))+"'" + toDate = "'"+str(fields.Datetime.to_string(to_local))+"'" mo_ids = self.env['mrp.production'].search([ ('state', '=', 'done'), @@ -272,6 +272,7 @@ class SamashtiDashboard(models.AbstractModel): 'date':mo.date_start.strftime('%d-%m-%Y'), 'tags':product_tags, 'uom': l.uom_id.name, + 'weight': l.quantity * (l.product_id.weight or 1), 'quantity':l.quantity, 'value':l.value, 'reference':l.reference diff --git a/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_consumption_dashboard.js b/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_consumption_dashboard.js index 5103b95ab..c16cf9280 100644 --- a/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_consumption_dashboard.js +++ b/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_consumption_dashboard.js @@ -216,6 +216,7 @@ export class ConsumptionDashboard extends Component { dataIndx: "uom", width: 80 }, + { title: "Weight (kgs)", dataIndx: "weight", width: 120, dataType: "float", format: "#,###.00", summary: { type: "sum_" }, align: "right"}, { title: "Value (INR)", dataIndx: "value", diff --git a/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_sale_dashboard.js b/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_sale_dashboard.js index 3c204af43..d1d77c170 100644 --- a/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_sale_dashboard.js +++ b/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_sale_dashboard.js @@ -134,7 +134,7 @@ export class SaleDashboard extends Component { { title: "Customer", dataIndx: "customer", width: 280, filter: { type: 'textbox', condition: 'contain', listeners: ['keyup'] } }, { title: "Tags", dataIndx: "tags", width: 100, }, { title: "Quantity (Bags/No's)", dataIndx: "quantity", width: 150, dataType: "float", format: "#,###.00", summary: { type: "sum_" }, align: "right" }, - { title: "Weight (kgs)", dataIndx: "weight", width: 120 }, + { title: "Weight (kgs)", dataIndx: "weight", width: 120, dataType: "float", format: "#,###.00", summary: { type: "sum_" }, align: "right"}, { title: "Production Cost (INR)", dataIndx: "cost", width: 150, dataType: "float", format: "#,###.00", summary: { type: "sum_" }, align: "right" }, { title: "Sale Price (INR)", dataIndx: "sale_price", width: 120, dataType: "float", format: "#,###.00", summary: { type: "sum_" }, align: "right" }, { title: "Margin (INR)", dataIndx: "margin", width: 120, dataType: "float", format: "#,###.00", summary: { type: "sum_" }, align: "right" },