code update
This commit is contained in:
parent
789d66ef28
commit
f6af6b3260
|
|
@ -5,6 +5,7 @@ from functools import reduce
|
||||||
|
|
||||||
from datetime import datetime, time
|
from datetime import datetime, time
|
||||||
|
|
||||||
|
|
||||||
class SamashtiDashboard(models.AbstractModel):
|
class SamashtiDashboard(models.AbstractModel):
|
||||||
_name = 'samashti.board'
|
_name = 'samashti.board'
|
||||||
_description = "Samashti Dashboard"
|
_description = "Samashti Dashboard"
|
||||||
|
|
@ -126,8 +127,10 @@ class SamashtiDashboard(models.AbstractModel):
|
||||||
data = self.env.cr.dictfetchall()
|
data = self.env.cr.dictfetchall()
|
||||||
if data:
|
if data:
|
||||||
for row in data:
|
for row in data:
|
||||||
row['product_name'] = '['+row['product_code']+'] '+ list(row['product_name'].values())[0] if row['product_name'] else ''
|
row['product_name'] = '[' + row['product_code'] + '] ' + list(row['product_name'].values())[0] if row[
|
||||||
row['uom'] = list(row['uom'].values())[0] if row['uom'] else '-'
|
'product_name'] else ''
|
||||||
|
row['uom'] = list(row['uom'].values())[0] if row['uom'] else '-'
|
||||||
|
row['value'] = row['closing_stock'] * row['current_cost']
|
||||||
return data
|
return data
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
@ -158,6 +161,7 @@ class SamashtiDashboard(models.AbstractModel):
|
||||||
|
|
||||||
datas.append({
|
datas.append({
|
||||||
'sale_order': r['name'],
|
'sale_order': r['name'],
|
||||||
|
'id':r['id'],
|
||||||
'weight':weight,
|
'weight':weight,
|
||||||
'customer':customer,
|
'customer':customer,
|
||||||
'quantity':quantity,
|
'quantity':quantity,
|
||||||
|
|
@ -221,5 +225,12 @@ class SamashtiDashboard(models.AbstractModel):
|
||||||
|
|
||||||
return cost
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
//import { standardWidgetProps } from "@web/views/widgets/standard_widget_props";
|
//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 { Component, onMounted, useRef, useState, onWillStart } from "@odoo/owl";
|
||||||
import { registry } from "@web/core/registry";
|
import { registry } from "@web/core/registry";
|
||||||
import { useService } from "@web/core/utils/hooks";
|
import { useService } from "@web/core/utils/hooks";
|
||||||
import { loadJS, loadCSS,loadBundle } from "@web/core/assets";
|
import { loadJS, loadCSS,loadBundle } from "@web/core/assets";
|
||||||
|
|
||||||
export class SamashtiDashboard extends Component {
|
export class SamashtiDashboard extends Component {
|
||||||
// static props = {
|
static props = {
|
||||||
// ...standardWidgetProps,
|
...standardActionServiceProps,
|
||||||
// };
|
};
|
||||||
|
|
||||||
static template = "SamashtiDashboard";
|
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: "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: "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: "Uom", dataIndx: "uom", width: 90, dataType:"text" },
|
||||||
|
{ title: "Value", dataIndx: "value", width: 120, dataType: "float", format: "#,###.00",summary: { type: "sum" },align: "right" },
|
||||||
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
async getSaleColumns(){
|
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: "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", 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: "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 "<button class='row-btn-view' type='button' >View</button>"
|
||||||
|
},
|
||||||
|
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%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
editable: false,
|
editable: false,
|
||||||
|
postRenderInterval: -1,
|
||||||
stripeRows: true,
|
stripeRows: true,
|
||||||
filterModel: { on: true, mode: "AND", header: true, autoSearch: true, type: 'local', minLength: 1 },
|
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" },
|
dataModel: { data: this.state.sale_rows, location: "local", sorting: "local", paging: "local" },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue