[stock reco] cleanups
This commit is contained in:
parent
8c0f05fbae
commit
0fb678e7cf
@ -22,7 +22,7 @@ frappe.ui.form.on("Stock Reconciliation", "get_items", function(frm) {
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
, __("Get Items"), __("Update"));
|
||||
});
|
||||
|
||||
erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
@ -51,7 +51,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
|
||||
setup: function() {
|
||||
var me = this;
|
||||
this.frm.get_field("items").grid.allow_build_edit();
|
||||
this.frm.get_docfield("items").allow_bulk_edit = 1;
|
||||
|
||||
if (sys_defaults.auto_accounting_for_stock) {
|
||||
this.frm.add_fetch("company", "stock_adjustment_account", "expense_account");
|
||||
@ -77,29 +77,12 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
//
|
||||
if(this.frm.doc.docstatus==1) {
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
}
|
||||
},
|
||||
|
||||
// show_download_template: function() {
|
||||
// var me = this;
|
||||
// this.frm.add_custom_button(__("Download Template"), function() {
|
||||
// this.title = __("Stock Reconcilation Template");
|
||||
// frappe.tools.downloadify([[__("Stock Reconciliation")],
|
||||
// ["----"],
|
||||
// [__("Stock Reconciliation can be used to update the stock on a particular date, usually as per physical inventory.")],
|
||||
// [__("When submitted, the system creates difference entries to set the given stock and valuation on this date.")],
|
||||
// [__("It can also be used to create opening stock entries and to fix stock value.")],
|
||||
// ["----"],
|
||||
// [__("Notes:")],
|
||||
// [__("Item Code and Warehouse should already exist.")],
|
||||
// [__("You can update either Quantity or Valuation Rate or both.")],
|
||||
// [__("If no change in either Quantity or Valuation Rate, leave the cell blank.")],
|
||||
// ["----"],
|
||||
// ["Item Code", "Warehouse", "Quantity", "Valuation Rate"]], null, this);
|
||||
// return false;
|
||||
// }, "icon-download");
|
||||
// },
|
||||
|
||||
});
|
||||
|
||||
cur_frm.cscript = new erpnext.stock.StockReconciliation({frm: cur_frm});
|
||||
|
@ -33,11 +33,12 @@ class StockReconciliation(StockController):
|
||||
self.validation_messages = []
|
||||
item_warehouse_combinations = []
|
||||
|
||||
default_currency = frappe.db.get_default("currency")
|
||||
|
||||
# validate no of rows
|
||||
rows = self.items
|
||||
if len(rows) > 100:
|
||||
if len(self.items) > 100:
|
||||
frappe.throw(_("""Max 100 rows for Stock Reconciliation."""))
|
||||
for row_num, row in enumerate(rows):
|
||||
for row_num, row in enumerate(self.items):
|
||||
# find duplicates
|
||||
if [row.item_code, row.warehouse] in item_warehouse_combinations:
|
||||
self.validation_messages.append(_get_msg(row_num, _("Duplicate entry")))
|
||||
@ -65,6 +66,13 @@ class StockReconciliation(StockController):
|
||||
self.validation_messages.append(_get_msg(row_num,
|
||||
_("Negative Valuation Rate is not allowed")))
|
||||
|
||||
if row.qty and not row.valuation_rate:
|
||||
# try if there is a buying price list in default currency
|
||||
buying_rate = frappe.db.get_value("Item Price", {"item_code": row.item_code,
|
||||
"buying": 1, "currency": default_currency}, "price_list_rate")
|
||||
if buying_rate:
|
||||
row.valuation_rate = buying_rate
|
||||
|
||||
# throw all validation messages
|
||||
if self.validation_messages:
|
||||
for msg in self.validation_messages:
|
||||
|
Loading…
x
Reference in New Issue
Block a user