[wip] batch, serial number selector

This commit is contained in:
Rushabh Mehta 2017-05-04 09:35:19 +05:30 committed by pratu16x7
parent 2cb598f644
commit aedaac63ea
7 changed files with 3176 additions and 3137 deletions

View File

@ -105,8 +105,9 @@ def set_batch_nos(doc, warehouse_field, throw = False):
if flt(batch_qty) < flt(d.qty): 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)) 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): def get_batch_no(item_code, warehouse, qty):
'''get the smallest batch with for the given item_code, warehouse and qty''' '''get the batch number with for the given item_code, warehouse and qty if there
is only one batch'''
batch_no = None batch_no = None
batches = get_batch_qty(item_code = item_code, warehouse = warehouse) batches = get_batch_qty(item_code = item_code, warehouse = warehouse)

View File

@ -1457,7 +1457,7 @@
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Batch No", "label": "Batch No",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 1,
"oldfieldname": "batch_no", "oldfieldname": "batch_no",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Batch", "options": "Batch",
@ -1597,7 +1597,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": ":Company", "default": ":Company",
"depends_on": "", "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
"fieldname": "cost_center", "fieldname": "cost_center",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,

View File

@ -542,3 +542,35 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
erpnext.utils.get_party_details(this.frm, null, null, null); 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},
],
}
]
});
}
}

View File

@ -52,7 +52,7 @@ class StockEntry(StockController):
if self._action == 'submit': if self._action == 'submit':
self.make_batches('t_warehouse') self.make_batches('t_warehouse')
else: else:
set_batch_nos(self, 's_warehouse', True) set_batch_nos(self, 's_warehouse')
self.set_actual_qty() self.set_actual_qty()
self.calculate_rate_and_amount(update_finished_item_rate=False) self.calculate_rate_and_amount(update_finished_item_rate=False)

View File

@ -6,11 +6,12 @@ frappe.listview_settings['Stock Entry'] = {
var html = ""; var html = "";
if(doc.from_warehouse) { if(doc.from_warehouse) {
html += '<span class="filterable h6"\ html += '<span class="filterable h6"\
data-filter="from_warehouse,=,'+doc.from_warehouse+'">'+doc.from_warehouse+' </span>'; 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> ';
} }
// if(doc.from_warehouse || doc.to_warehouse) {
// html += '<i class="fa fa-arrow-right text-muted"></i> ';
// }
if(doc.to_warehouse) { if(doc.to_warehouse) {
html += '<span class="filterable h6"\ html += '<span class="filterable h6"\
data-filter="to_warehouse,=,'+doc.to_warehouse+'">'+doc.to_warehouse+'</span>'; data-filter="to_warehouse,=,'+doc.to_warehouse+'">'+doc.to_warehouse+'</span>';

View File

@ -822,7 +822,7 @@
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Serial No / Batch", "label": "Serial No / Batch",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 1,
"permlevel": 0, "permlevel": 0,
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
@ -910,7 +910,7 @@
"in_standard_filter": 0, "in_standard_filter": 0,
"label": "Batch No", "label": "Batch No",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 1,
"oldfieldname": "batch_no", "oldfieldname": "batch_no",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Batch", "options": "Batch",
@ -960,7 +960,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "", "depends_on": "eval:cint(frappe.sys_defaults.auto_accounting_for_stock)",
"fieldname": "expense_account", "fieldname": "expense_account",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@ -1020,7 +1020,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": ":Company", "default": ":Company",
"depends_on": "", "depends_on": "eval:cint(frappe.sys_defaults.auto_accounting_for_stock)",
"fieldname": "cost_center", "fieldname": "cost_center",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,

View File

@ -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 # syste does not found any SLE, then take valuation rate from Item
valuation_rate = frappe.db.get_value("Item", item_code, "valuation_rate") valuation_rate = frappe.db.get_value("Item", item_code, "valuation_rate")
if not valuation_rate:
# try Item Standard rate
valuation_rate = frappe.db.get_value("Item", item_code, "standard_rate")
if not valuation_rate: if not valuation_rate:
# try in price list # try in price list
valuation_rate = frappe.db.get_value('Item Price', valuation_rate = frappe.db.get_value('Item Price',
dict(item_code=item_code, buying=1, currency=currency), 'price_list_rate') dict(item_code=item_code, buying=1, currency=currency),
'price_list_rate')
if not allow_zero_rate and not valuation_rate \ if not allow_zero_rate and not valuation_rate \
and cint(erpnext.is_perpetual_inventory_enabled(company)): and cint(erpnext.is_perpetual_inventory_enabled(company)):