Merge pull request #24921 from Anurag810/item-dashboard-fixes
fix: precision and formatted document for stock level in item dashboard.
This commit is contained in:
commit
c6b3766fb2
@ -17,19 +17,22 @@ erpnext.stock.ItemDashboard = Class.extend({
|
|||||||
this.result = this.content.find('.result');
|
this.result = this.content.find('.result');
|
||||||
|
|
||||||
this.content.on('click', '.btn-move', function () {
|
this.content.on('click', '.btn-move', function () {
|
||||||
handle_move_add($(this), "Move")
|
handle_move_add($(this), "Move");
|
||||||
});
|
});
|
||||||
|
|
||||||
this.content.on('click', '.btn-add', function () {
|
this.content.on('click', '.btn-add', function () {
|
||||||
handle_move_add($(this), "Add")
|
handle_move_add($(this), "Add");
|
||||||
});
|
});
|
||||||
|
|
||||||
this.content.on('click', '.btn-edit', function () {
|
this.content.on('click', '.btn-edit', function () {
|
||||||
let item = unescape($(this).attr('data-item'));
|
let item = unescape($(this).attr('data-item'));
|
||||||
let warehouse = unescape($(this).attr('data-warehouse'));
|
let warehouse = unescape($(this).attr('data-warehouse'));
|
||||||
let company = unescape($(this).attr('data-company'));
|
let company = unescape($(this).attr('data-company'));
|
||||||
frappe.db.get_value('Putaway Rule',
|
frappe.db.get_value('Putaway Rule', {
|
||||||
{'item_code': item, 'warehouse': warehouse, 'company': company}, 'name', (r) => {
|
'item_code': item,
|
||||||
|
'warehouse': warehouse,
|
||||||
|
'company': company
|
||||||
|
}, 'name', (r) => {
|
||||||
frappe.set_route("Form", "Putaway Rule", r.name);
|
frappe.set_route("Form", "Putaway Rule", r.name);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -46,10 +49,13 @@ erpnext.stock.ItemDashboard = Class.extend({
|
|||||||
} else {
|
} else {
|
||||||
if (action === "Add") {
|
if (action === "Add") {
|
||||||
let rate = unescape($(this).attr('data-rate'));
|
let rate = unescape($(this).attr('data-rate'));
|
||||||
erpnext.stock.move_item(item, null, warehouse, actual_qty, rate, function() { me.refresh(); });
|
erpnext.stock.move_item(item, null, warehouse, actual_qty, rate, function () {
|
||||||
}
|
me.refresh();
|
||||||
else {
|
});
|
||||||
erpnext.stock.move_item(item, warehouse, null, actual_qty, null, function() { me.refresh(); });
|
} else {
|
||||||
|
erpnext.stock.move_item(item, warehouse, null, actual_qty, null, function () {
|
||||||
|
me.refresh();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,7 +70,7 @@ erpnext.stock.ItemDashboard = Class.extend({
|
|||||||
row.s_warehouse = warehouse;
|
row.s_warehouse = warehouse;
|
||||||
|
|
||||||
frappe.set_route('Form', doc.doctype, doc.name);
|
frappe.set_route('Form', doc.doctype, doc.name);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// more
|
// more
|
||||||
@ -188,18 +194,42 @@ erpnext.stock.ItemDashboard = Class.extend({
|
|||||||
erpnext.stock.move_item = function (item, source, target, actual_qty, rate, callback) {
|
erpnext.stock.move_item = function (item, source, target, actual_qty, rate, callback) {
|
||||||
var dialog = new frappe.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
title: target ? __('Add Item') : __('Move Item'),
|
title: target ? __('Add Item') : __('Move Item'),
|
||||||
fields: [
|
fields: [{
|
||||||
{fieldname: 'item_code', label: __('Item'),
|
fieldname: 'item_code',
|
||||||
fieldtype: 'Link', options: 'Item', read_only: 1},
|
label: __('Item'),
|
||||||
{fieldname: 'source', label: __('Source Warehouse'),
|
fieldtype: 'Link',
|
||||||
fieldtype: 'Link', options: 'Warehouse', read_only: 1},
|
options: 'Item',
|
||||||
{fieldname: 'target', label: __('Target Warehouse'),
|
read_only: 1
|
||||||
fieldtype: 'Link', options: 'Warehouse', reqd: 1},
|
},
|
||||||
{fieldname: 'qty', label: __('Quantity'), reqd: 1,
|
{
|
||||||
fieldtype: 'Float', description: __('Available {0}', [actual_qty]) },
|
fieldname: 'source',
|
||||||
{fieldname: 'rate', label: __('Rate'), fieldtype: 'Currency', hidden: 1 },
|
label: __('Source Warehouse'),
|
||||||
|
fieldtype: 'Link',
|
||||||
|
options: 'Warehouse',
|
||||||
|
read_only: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: 'target',
|
||||||
|
label: __('Target Warehouse'),
|
||||||
|
fieldtype: 'Link',
|
||||||
|
options: 'Warehouse',
|
||||||
|
reqd: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: 'qty',
|
||||||
|
label: __('Quantity'),
|
||||||
|
reqd: 1,
|
||||||
|
fieldtype: 'Float',
|
||||||
|
description: __('Available {0}', [actual_qty])
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: 'rate',
|
||||||
|
label: __('Rate'),
|
||||||
|
fieldtype: 'Currency',
|
||||||
|
hidden: 1
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})
|
});
|
||||||
dialog.show();
|
dialog.show();
|
||||||
dialog.get_field('item_code').set_input(item);
|
dialog.get_field('item_code').set_input(item);
|
||||||
|
|
||||||
@ -248,8 +278,8 @@ erpnext.stock.move_item = function(item, source, target, actual_qty, rate, callb
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('<p style="margin-left: 10px;"><a class="link-open text-muted small">'
|
$('<p style="margin-left: 10px;"><a class="link-open text-muted small">' +
|
||||||
+ __("Add more items or open full form") + '</a></p>')
|
__("Add more items or open full form") + '</a></p>')
|
||||||
.appendTo(dialog.body)
|
.appendTo(dialog.body)
|
||||||
.find('.link-open')
|
.find('.link-open')
|
||||||
.on('click', function () {
|
.on('click', function () {
|
||||||
@ -266,6 +296,6 @@ erpnext.stock.move_item = function(item, source, target, actual_qty, rate, callb
|
|||||||
row.transfer_qty = dialog.get_value('qty');
|
row.transfer_qty = dialog.get_value('qty');
|
||||||
row.basic_rate = dialog.get_value('rate');
|
row.basic_rate = dialog.get_value('rate');
|
||||||
frappe.set_route('Form', doc.doctype, doc.name);
|
frappe.set_route('Form', doc.doctype, doc.name);
|
||||||
})
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
};
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.db_query import DatabaseQuery
|
from frappe.model.db_query import DatabaseQuery
|
||||||
|
from frappe.utils import flt, cint
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_data(item_code=None, warehouse=None, item_group=None,
|
def get_data(item_code=None, warehouse=None, item_group=None,
|
||||||
@ -42,11 +43,20 @@ def get_data(item_code=None, warehouse=None, item_group=None,
|
|||||||
limit_start=start,
|
limit_start=start,
|
||||||
limit_page_length='21')
|
limit_page_length='21')
|
||||||
|
|
||||||
|
precision = cint(frappe.db.get_single_value("System Settings", "float_precision"))
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
item.update({
|
item.update({
|
||||||
'item_name': frappe.get_cached_value("Item", item.item_code, 'item_name'),
|
'item_name': frappe.get_cached_value(
|
||||||
'disable_quick_entry': frappe.get_cached_value("Item", item.item_code, 'has_batch_no')
|
"Item", item.item_code, 'item_name'),
|
||||||
or frappe.get_cached_value("Item", item.item_code, 'has_serial_no'),
|
'disable_quick_entry': frappe.get_cached_value(
|
||||||
|
"Item", item.item_code, 'has_batch_no')
|
||||||
|
or frappe.get_cached_value(
|
||||||
|
"Item", item.item_code, 'has_serial_no'),
|
||||||
|
'projected_qty': flt(item.projected_qty, precision),
|
||||||
|
'reserved_qty': flt(item.reserved_qty, precision),
|
||||||
|
'reserved_qty_for_production': flt(item.reserved_qty_for_production, precision),
|
||||||
|
'reserved_qty_for_sub_contract': flt(item.reserved_qty_for_sub_contract, precision),
|
||||||
|
'actual_qty': flt(item.actual_qty, precision),
|
||||||
})
|
})
|
||||||
|
|
||||||
return items
|
return items
|
||||||
|
Loading…
x
Reference in New Issue
Block a user