From f6af6b3260180a67d7cbc7280998f79fe4a85a27 Mon Sep 17 00:00:00 2001 From: raman Date: Tue, 4 Nov 2025 13:57:23 +0530 Subject: [PATCH] code update --- .../dashboard/models/stock_dashboard.py | 15 +++++++-- .../pqgrid_stock_dashboard.js | 33 +++++++++++++++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/custom_addons/dashboard/models/stock_dashboard.py b/custom_addons/dashboard/models/stock_dashboard.py index 7da2573f4..7155af4f9 100644 --- a/custom_addons/dashboard/models/stock_dashboard.py +++ b/custom_addons/dashboard/models/stock_dashboard.py @@ -5,6 +5,7 @@ from functools import reduce from datetime import datetime, time + class SamashtiDashboard(models.AbstractModel): _name = 'samashti.board' _description = "Samashti Dashboard" @@ -126,8 +127,10 @@ class SamashtiDashboard(models.AbstractModel): data = self.env.cr.dictfetchall() if data: for row in data: - row['product_name'] = '['+row['product_code']+'] '+ list(row['product_name'].values())[0] if row['product_name'] else '' - row['uom'] = list(row['uom'].values())[0] if row['uom'] else '-' + row['product_name'] = '[' + row['product_code'] + '] ' + list(row['product_name'].values())[0] if row[ + 'product_name'] else '' + row['uom'] = list(row['uom'].values())[0] if row['uom'] else '-' + row['value'] = row['closing_stock'] * row['current_cost'] return data else: return [] @@ -158,6 +161,7 @@ class SamashtiDashboard(models.AbstractModel): datas.append({ 'sale_order': r['name'], + 'id':r['id'], 'weight':weight, 'customer':customer, 'quantity':quantity, @@ -221,5 +225,12 @@ class SamashtiDashboard(models.AbstractModel): return cost + def action_view_sale_orders(self, id): + result = self.env['ir.actions.act_window']._for_xml_id('sale.action_orders') + result['views'] = [(self.env.ref('sale.view_order_form', False).id, 'form')] + result['res_id'] = id + result['target'] = 'self', + return result + diff --git a/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_stock_dashboard.js b/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_stock_dashboard.js index ace0d611b..4bfb0c888 100644 --- a/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_stock_dashboard.js +++ b/custom_addons/dashboard/static/src/components/pqgrid_dashboard/pqgrid_stock_dashboard.js @@ -1,14 +1,16 @@ /** @odoo-module **/ //import { standardWidgetProps } from "@web/views/widgets/standard_widget_props"; +import { standardActionServiceProps } from "@web/webclient/actions/action_service"; + import { Component, onMounted, useRef, useState, onWillStart } from "@odoo/owl"; import { registry } from "@web/core/registry"; import { useService } from "@web/core/utils/hooks"; import { loadJS, loadCSS,loadBundle } from "@web/core/assets"; export class SamashtiDashboard extends Component { -// static props = { -// ...standardWidgetProps, -// }; + static props = { + ...standardActionServiceProps, + }; static template = "SamashtiDashboard"; @@ -167,6 +169,8 @@ export class SamashtiDashboard extends Component { { title: "Dispatch", dataIndx: "dispatch", width: 120, dataType: "float", format: "#,###.00",summary: { type: "sum" },align: "right" }, { title: "Closing Stock", dataIndx: "closing_stock", width: 120, dataType: "float", format: "#,###.00",summary: { type: "sum" },align: "right" }, { title: "Uom", dataIndx: "uom", width: 90, dataType:"text" }, + { title: "Value", dataIndx: "value", width: 120, dataType: "float", format: "#,###.00",summary: { type: "sum" },align: "right" }, + ]; } async getSaleColumns(){ @@ -180,6 +184,28 @@ export class SamashtiDashboard extends Component { { title: "Sale Price", dataIndx: "sale_price", width: 120, dataType: "float", format: "#,###.00",summary: { type: "sum" },align: "right" }, { title: "Margin", dataIndx: "margin", width: 120, dataType: "float", format: "#,###.00",summary: { type: "sum" },align: "right" }, { title: "Margin %", dataIndx: "margin_percent", width: 120, dataType: "float", format: "#,###.00",summary: { type: "sum" },align: "right" }, + { + title: "View", + width: 120, + editable: false, + summary:false, + render: function (ui) { + return "" + }, + postRender: function (ui) { + var grid = this, + $cell = grid.getCell(ui); + $cell.find(".row-btn-view") + .button({ icons: { primary: 'ui-icon-extlink'} }) + .on("click", async function (evt) { + const res = await odoo.__WOWL_DEBUG__.root.orm.call('samashti.board','action_view_sale_orders',[ui.rowData.id,ui.rowData.id]) +// res.views = [[false, "form"]], + res.target = "new" + await odoo.__WOWL_DEBUG__.root.actionService.doAction(res) + }); + } + + }, ] } @@ -273,6 +299,7 @@ export class SamashtiDashboard extends Component { width: "100%", height: "100%", editable: false, + postRenderInterval: -1, stripeRows: true, filterModel: { on: true, mode: "AND", header: true, autoSearch: true, type: 'local', minLength: 1 }, dataModel: { data: this.state.sale_rows, location: "local", sorting: "local", paging: "local" },