[wip] batch, serial number selector
This commit is contained in:
parent
2cb598f644
commit
aedaac63ea
@ -105,9 +105,10 @@ 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)
|
||||
if batches:
|
||||
@ -117,7 +118,7 @@ def get_batch_no(item_code, warehouse, qty, throw=False):
|
||||
batch_no = b.batch_no
|
||||
# found!
|
||||
break
|
||||
|
||||
|
||||
if not batch_no:
|
||||
frappe.msgprint(_('Please select a Batch for Item {0}. Unable to find a single batch that fulfills this requirement').format(frappe.bold(item_code)))
|
||||
if throw: raise UnableToSelectBatchError
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -524,7 +524,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
} else {
|
||||
doc.customer = doc.customer_name = doc.customer_address =
|
||||
doc.delivery_note_no = doc.sales_invoice_no = doc.supplier =
|
||||
doc.supplier_name = doc.supplier_address = doc.purchase_receipt_no =
|
||||
doc.supplier_name = doc.supplier_address = doc.purchase_receipt_no =
|
||||
doc.address_display = null;
|
||||
}
|
||||
if(doc.purpose == "Material Receipt") {
|
||||
@ -541,4 +541,36 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
supplier: function(doc) {
|
||||
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>';
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -259,7 +259,7 @@ class update_entries_after(object):
|
||||
if not self.valuation_rate and actual_qty > 0:
|
||||
self.valuation_rate = sle.incoming_rate
|
||||
|
||||
# Get valuation rate from previous SLE or Item master, if item does not have the
|
||||
# Get valuation rate from previous SLE or Item master, if item does not have the
|
||||
# allow zero valuration rate flag set
|
||||
if not self.valuation_rate and sle.voucher_detail_no:
|
||||
allow_zero_valuation_rate = self.check_if_allow_zero_valuation_rate(sle.voucher_type, sle.voucher_detail_no)
|
||||
@ -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