code update
This commit is contained in:
parent
789d66ef28
commit
f6af6b3260
|
|
@ -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['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
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 "<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%",
|
||||
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" },
|
||||
|
|
|
|||
Loading…
Reference in New Issue