Merge pull request #4396 from rmehta/stock-reco-fixes
[fixes] stock reco, must always set qty and rate
This commit is contained in:
commit
3f10e0ba2d
@ -33,11 +33,7 @@ A predefined template of an spreadsheet file should be followed for importing it
|
||||
|
||||
![Stock Reco Data]({{url_prefix}}/assets/old_images/erpnext/stock-reco-data.png)
|
||||
|
||||
The csv format is case-sensitive. Do not edit the headers which are preset in the template. In the Item Code and Warehouse column, enter exact Item Code and Warehouse as created in your ERPNext account. For quatity, enter stock level you wish to set for that item, in a specific warehouse. If you do not want to change the quantity or valuation rate of an Item, you should leave it blank.
|
||||
|
||||
Note: Make sure you do not put zero if you do not want to change the quantity
|
||||
amount or valuation amount. The system will calculate zero as zero quantity.
|
||||
So leave the field blank.
|
||||
The csv format is case-sensitive. Do not edit the headers which are preset in the template. In the Item Code and Warehouse column, enter exact Item Code and Warehouse as created in your ERPNext account. For quatity, enter stock level you wish to set for that item, in a specific warehouse.
|
||||
|
||||
#### **Step 3: Upload file and Enter Values in Stock Reconciliation Form
|
||||
|
||||
|
@ -5,28 +5,89 @@ frappe.require("assets/erpnext/js/controllers/stock_controller.js");
|
||||
frappe.require("assets/erpnext/js/utils.js");
|
||||
frappe.provide("erpnext.stock");
|
||||
|
||||
frappe.ui.form.on("Stock Reconciliation", "get_items", function(frm) {
|
||||
frappe.prompt({label:"Warehouse", fieldtype:"Link", options:"Warehouse", reqd: 1},
|
||||
function(data) {
|
||||
frappe.ui.form.on("Stock Reconciliation", {
|
||||
onload: function(frm) {
|
||||
// end of life
|
||||
frm.set_query("item_code", "items", function(doc, cdt, cdn) {
|
||||
return {
|
||||
filters:[
|
||||
['Item', 'end_of_life', '>=', frappe.datetime.nowdate()]
|
||||
]
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.docstatus < 1) {
|
||||
frm.add_custom_button(__("Get Items"), function() {
|
||||
frm.events.get_items(frm);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
company: function(frm) {
|
||||
erpnext.get_fiscal_year(frm.doc.company, frm.doc.posting_date);
|
||||
},
|
||||
|
||||
posting_date: function(frm) {
|
||||
erpnext.get_fiscal_year(frm.doc.company, frm.doc.posting_date);
|
||||
},
|
||||
|
||||
get_items: function(frm) {
|
||||
frappe.prompt({label:"Warehouse", fieldtype:"Link", options:"Warehouse", reqd: 1},
|
||||
function(data) {
|
||||
frappe.call({
|
||||
method:"erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_items",
|
||||
args: {
|
||||
warehouse: data.warehouse,
|
||||
posting_date: frm.doc.posting_date,
|
||||
posting_time: frm.doc.posting_time
|
||||
},
|
||||
callback: function(r) {
|
||||
var items = [];
|
||||
frm.clear_table("items");
|
||||
for(var i=0; i< r.message.length; i++) {
|
||||
var d = frm.add_child("items");
|
||||
$.extend(d, r.message[i]);
|
||||
if(!d.qty) d.qty = null;
|
||||
if(!d.valuation_rate) d.valuation_rate = null;
|
||||
}
|
||||
frm.refresh_field("items");
|
||||
}
|
||||
});
|
||||
}
|
||||
, __("Get Items"), __("Update"));
|
||||
},
|
||||
|
||||
set_valuation_rate_and_qty: function(frm, cdt, cdn) {
|
||||
var d = frappe.model.get_doc(cdt, cdn);
|
||||
if(d.item_code && d.warehouse) {
|
||||
frappe.call({
|
||||
method:"erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_items",
|
||||
method: "erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.get_stock_balance_for",
|
||||
args: {
|
||||
warehouse: data.warehouse,
|
||||
item_code: d.item_code,
|
||||
warehouse: d.warehouse,
|
||||
posting_date: frm.doc.posting_date,
|
||||
posting_time: frm.doc.posting_time
|
||||
},
|
||||
callback: function(r) {
|
||||
var items = [];
|
||||
frm.clear_table("items");
|
||||
for(var i=0; i< r.message.length; i++) {
|
||||
var d = frm.add_child("items");
|
||||
$.extend(d, r.message[i]);
|
||||
}
|
||||
frm.refresh_field("items");
|
||||
frappe.model.set_value(cdt, cdn, "qty", r.message.qty);
|
||||
frappe.model.set_value(cdt, cdn, "valuation_rate", r.message.rate);
|
||||
frappe.model.set_value(cdt, cdn, "current_qty", r.message.qty);
|
||||
frappe.model.set_value(cdt, cdn, "current_valuation_rate", r.message.rate);
|
||||
}
|
||||
});
|
||||
}
|
||||
, __("Get Items"), __("Update"));
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Stock Reconciliation Item", {
|
||||
warehouse: function(frm, cdt, cdn) {
|
||||
frm.events.set_valuation_rate_and_qty(frm, cdt, cdn);
|
||||
},
|
||||
item_code: function(frm, cdt, cdn) {
|
||||
frm.events.set_valuation_rate_and_qty(frm, cdt, cdn);
|
||||
}
|
||||
});
|
||||
|
||||
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
@ -93,19 +154,3 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
});
|
||||
|
||||
cur_frm.cscript = new erpnext.stock.StockReconciliation({frm: cur_frm});
|
||||
|
||||
cur_frm.cscript.company = function(doc, cdt, cdn) {
|
||||
erpnext.get_fiscal_year(doc.company, doc.posting_date);
|
||||
}
|
||||
|
||||
cur_frm.cscript.posting_date = function(doc, cdt, cdn){
|
||||
erpnext.get_fiscal_year(doc.company, doc.posting_date);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.items.grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
||||
return {
|
||||
filters:[
|
||||
['Item', 'end_of_life', '>=', frappe.datetime.nowdate()]
|
||||
]
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@
|
||||
"oldfieldtype": "Date",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
@ -51,6 +52,7 @@
|
||||
"oldfieldtype": "Time",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
@ -72,6 +74,7 @@
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -95,6 +98,7 @@
|
||||
"options": "Stock Reconciliation",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -118,6 +122,7 @@
|
||||
"options": "Company",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
@ -140,6 +145,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -164,6 +170,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
@ -171,29 +178,6 @@
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"fieldname": "get_items",
|
||||
"fieldtype": "Button",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 0,
|
||||
"label": "Get Items",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
@ -209,6 +193,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -233,6 +218,7 @@
|
||||
"options": "Account",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -257,6 +243,7 @@
|
||||
"options": "Cost Center",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -279,6 +266,7 @@
|
||||
"no_copy": 1,
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -301,6 +289,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -324,6 +313,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -346,6 +336,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -368,6 +359,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -391,6 +383,7 @@
|
||||
"options": "Fiscal Year",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
@ -409,7 +402,8 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 1,
|
||||
"modified": "2015-11-16 06:29:58.376911",
|
||||
"menu_index": 0,
|
||||
"modified": "2015-11-30 02:35:31.373161",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Reconciliation",
|
||||
|
@ -45,6 +45,13 @@ class StockReconciliation(StockController):
|
||||
if (item.qty==None or item.qty==qty) and (item.valuation_rate==None or item.valuation_rate==rate):
|
||||
return False
|
||||
else:
|
||||
# set default as current rates
|
||||
if item.qty==None:
|
||||
item.qty = qty
|
||||
|
||||
if item.valuation_rate==None:
|
||||
item.valuation_rate = rate
|
||||
|
||||
item.current_qty = qty
|
||||
item.current_valuation_rate = rate
|
||||
self.difference_amount += (flt(item.qty or qty) * flt(item.valuation_rate or rate) - (flt(qty) * flt(rate)))
|
||||
@ -254,3 +261,15 @@ def get_items(warehouse, posting_date, posting_time):
|
||||
del item["name"]
|
||||
|
||||
return items
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_stock_balance_for(item_code, warehouse, posting_date, posting_time):
|
||||
frappe.has_permission("Stock Reconciliation", "write", throw = True)
|
||||
|
||||
qty, rate = get_stock_balance(item_code, warehouse,
|
||||
posting_date, posting_time, with_valuation_rate=True)
|
||||
|
||||
return {
|
||||
'qty': qty,
|
||||
'rate': rate
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
@ -49,6 +50,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
@ -71,6 +73,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -82,7 +85,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"description": "Leave blank if no change",
|
||||
"description": "",
|
||||
"fieldname": "qty",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@ -95,6 +98,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -106,7 +110,7 @@
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"description": "Leave blank if no change",
|
||||
"description": "",
|
||||
"fieldname": "valuation_rate",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@ -119,6 +123,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -141,6 +146,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -165,6 +171,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -189,6 +196,7 @@
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
@ -199,13 +207,15 @@
|
||||
],
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 0,
|
||||
"in_create": 0,
|
||||
"in_dialog": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2015-11-16 06:29:58.445507",
|
||||
"menu_index": 0,
|
||||
"modified": "2015-11-30 02:34:10.385030",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Reconciliation Item",
|
||||
|
Loading…
x
Reference in New Issue
Block a user