[wip] batch, serial number selector
This commit is contained in:
parent
2cb598f644
commit
aedaac63ea
@ -105,8 +105,9 @@ def set_batch_nos(doc, warehouse_field, throw = False):
|
||||
if flt(batch_qty) < flt(d.qty):
|
||||
frappe.throw(_("Row #{0}: The batch {1} has only {2} qty. Please select another batch which has {3} qty available or split the row into multiple rows, to deliver/issue from multiple batches").format(d.idx, d.batch_no, batch_qty, d.qty))
|
||||
|
||||
def get_batch_no(item_code, warehouse, qty, throw=False):
|
||||
'''get the smallest batch with for the given item_code, warehouse and qty'''
|
||||
def get_batch_no(item_code, warehouse, qty):
|
||||
'''get the batch number with for the given item_code, warehouse and qty if there
|
||||
is only one batch'''
|
||||
|
||||
batch_no = None
|
||||
batches = get_batch_qty(item_code = item_code, warehouse = warehouse)
|
||||
|
@ -1457,7 +1457,7 @@
|
||||
"in_standard_filter": 0,
|
||||
"label": "Batch No",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "batch_no",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Batch",
|
||||
@ -1597,7 +1597,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": ":Company",
|
||||
"depends_on": "",
|
||||
"depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
|
@ -542,3 +542,35 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
erpnext.utils.get_party_details(this.frm, null, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
erpnext.select_batch_and_serial_no = (frm) => {
|
||||
frm.items.forEach(function(d) {
|
||||
if(d.has_batch_no && !d.batch_no) {
|
||||
show_modal(item_code, qty);
|
||||
}
|
||||
});
|
||||
|
||||
let show_modal = (item_code, qty) => {
|
||||
let d = new frappe.ui.Dialog({
|
||||
fields: [
|
||||
{fieldname: 'item_code', read_only: 1, fieldtype:'Link', options: 'Item',
|
||||
label: __('Item Code'), 'default': item_code},
|
||||
{fieldname: 'qty', fieldtype:'Float', label: __('Qty'), 'default': qty},
|
||||
{fieldname: 'batches', fieldtype: 'Table',
|
||||
fields: [
|
||||
{fieldtype:'Link', fieldname:'batch_no', options: 'Batch', reqd: 1,
|
||||
label: __('Select Batch'), in_list_view:1, get_query: function(doc) {
|
||||
return {filters: {item: item_code }};
|
||||
}},
|
||||
{fieldtype:'Float', fieldname:'available_qty', reqd: 1,
|
||||
label: __('Available'), in_list_view:1},
|
||||
{fieldtype:'Float', fieldname:'selected_qty', reqd: 1,
|
||||
label: __('Qty'), in_list_view:1},
|
||||
],
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -52,7 +52,7 @@ class StockEntry(StockController):
|
||||
if self._action == 'submit':
|
||||
self.make_batches('t_warehouse')
|
||||
else:
|
||||
set_batch_nos(self, 's_warehouse', True)
|
||||
set_batch_nos(self, 's_warehouse')
|
||||
|
||||
self.set_actual_qty()
|
||||
self.calculate_rate_and_amount(update_finished_item_rate=False)
|
||||
|
@ -6,11 +6,12 @@ frappe.listview_settings['Stock Entry'] = {
|
||||
var html = "";
|
||||
if(doc.from_warehouse) {
|
||||
html += '<span class="filterable h6"\
|
||||
data-filter="from_warehouse,=,'+doc.from_warehouse+'">'+doc.from_warehouse+' </span>';
|
||||
}
|
||||
if(doc.from_warehouse || doc.to_warehouse) {
|
||||
html += '<i class="octicon octfa fa-arrow-right text-muted"></i> ';
|
||||
data-filter="from_warehouse,=,'+doc.from_warehouse+'">'
|
||||
+doc.from_warehouse+' </span>';
|
||||
}
|
||||
// if(doc.from_warehouse || doc.to_warehouse) {
|
||||
// html += '<i class="fa fa-arrow-right text-muted"></i> ';
|
||||
// }
|
||||
if(doc.to_warehouse) {
|
||||
html += '<span class="filterable h6"\
|
||||
data-filter="to_warehouse,=,'+doc.to_warehouse+'">'+doc.to_warehouse+'</span>';
|
||||
|
@ -822,7 +822,7 @@
|
||||
"in_standard_filter": 0,
|
||||
"label": "Serial No / Batch",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"no_copy": 1,
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
@ -910,7 +910,7 @@
|
||||
"in_standard_filter": 0,
|
||||
"label": "Batch No",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "batch_no",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Batch",
|
||||
@ -960,7 +960,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"depends_on": "eval:cint(frappe.sys_defaults.auto_accounting_for_stock)",
|
||||
"fieldname": "expense_account",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@ -1020,7 +1020,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": ":Company",
|
||||
"depends_on": "",
|
||||
"depends_on": "eval:cint(frappe.sys_defaults.auto_accounting_for_stock)",
|
||||
"fieldname": "cost_center",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
|
@ -448,10 +448,15 @@ def get_valuation_rate(item_code, warehouse, voucher_type, voucher_no,
|
||||
# syste does not found any SLE, then take valuation rate from Item
|
||||
valuation_rate = frappe.db.get_value("Item", item_code, "valuation_rate")
|
||||
|
||||
if not valuation_rate:
|
||||
# try in price list
|
||||
valuation_rate = frappe.db.get_value('Item Price',
|
||||
dict(item_code=item_code, buying=1, currency=currency), 'price_list_rate')
|
||||
if not valuation_rate:
|
||||
# try Item Standard rate
|
||||
valuation_rate = frappe.db.get_value("Item", item_code, "standard_rate")
|
||||
|
||||
if not valuation_rate:
|
||||
# try in price list
|
||||
valuation_rate = frappe.db.get_value('Item Price',
|
||||
dict(item_code=item_code, buying=1, currency=currency),
|
||||
'price_list_rate')
|
||||
|
||||
if not allow_zero_rate and not valuation_rate \
|
||||
and cint(erpnext.is_perpetual_inventory_enabled(company)):
|
||||
|
Loading…
x
Reference in New Issue
Block a user