mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
WIP
This commit is contained in:
@@ -123,4 +123,10 @@ def get_batch_no(item_code, warehouse, qty):
|
|||||||
frappe.msgprint(_('Please select a Batch for Item {0}. Unable to find a single batch that fulfills this requirement').format(frappe.bold(item_code)))
|
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
|
if throw: raise UnableToSelectBatchError
|
||||||
|
|
||||||
|
# oldest_expiry_date = min([batch.expiry_date for batch in batches])
|
||||||
|
|
||||||
|
# for batch in batches:
|
||||||
|
# if batch.expiry_date == oldest_expiry_date:
|
||||||
|
# batch_no = batch.batch_no
|
||||||
|
|
||||||
return batch_no
|
return batch_no
|
||||||
@@ -43,6 +43,7 @@ frappe.ui.form.on('Stock Entry', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
|
erpnext.select_batch_and_serial_no(frm);
|
||||||
if(!frm.doc.docstatus) {
|
if(!frm.doc.docstatus) {
|
||||||
frm.add_custom_button(__('Make Material Request'), function() {
|
frm.add_custom_button(__('Make Material Request'), function() {
|
||||||
frappe.model.with_doctype('Material Request', function() {
|
frappe.model.with_doctype('Material Request', function() {
|
||||||
@@ -76,6 +77,10 @@ frappe.ui.form.on('Stock Entry', {
|
|||||||
frm.fields_dict.items.grid.refresh();
|
frm.fields_dict.items.grid.refresh();
|
||||||
frm.cscript.toggle_related_fields(frm.doc);
|
frm.cscript.toggle_related_fields(frm.doc);
|
||||||
},
|
},
|
||||||
|
before_save: function(frm) {
|
||||||
|
console.log("before_save");
|
||||||
|
erpnext.select_batch_and_serial_no(frm);
|
||||||
|
},
|
||||||
company: function(frm) {
|
company: function(frm) {
|
||||||
if(frm.doc.company) {
|
if(frm.doc.company) {
|
||||||
var company_doc = frappe.get_doc(":Company", frm.doc.company);
|
var company_doc = frappe.get_doc(":Company", frm.doc.company);
|
||||||
@@ -544,33 +549,54 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
erpnext.select_batch_and_serial_no = (frm) => {
|
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 show_modal = (item_code, qty) => {
|
||||||
let d = new frappe.ui.Dialog({
|
let d = new frappe.ui.Dialog({
|
||||||
fields: [
|
fields: [
|
||||||
{fieldname: 'item_code', read_only: 1, fieldtype:'Link', options: 'Item',
|
{fieldname: 'item_code', read_only: 1, fieldtype:'Link', options: 'Item',
|
||||||
label: __('Item Code'), 'default': item_code},
|
label: __('Item Code'), 'default': item_code},
|
||||||
|
{fieldtype:'Column Break'},
|
||||||
{fieldname: 'qty', fieldtype:'Float', label: __('Qty'), 'default': qty},
|
{fieldname: 'qty', fieldtype:'Float', label: __('Qty'), 'default': qty},
|
||||||
|
{fieldtype:'Section Break'},
|
||||||
{fieldname: 'batches', fieldtype: 'Table',
|
{fieldname: 'batches', fieldtype: 'Table',
|
||||||
fields: [
|
fields: [
|
||||||
{fieldtype:'Link', fieldname:'batch_no', options: 'Batch', reqd: 1,
|
{fieldtype:'Link', fieldname:'batch_no', options: 'Batch',
|
||||||
label: __('Select Batch'), in_list_view:1, get_query: function(doc) {
|
label: __('Select Batch'), in_list_view:1, get_query: function(doc) {
|
||||||
return {filters: {item: item_code }};
|
return {filters: {item: item_code }};
|
||||||
}},
|
}},
|
||||||
{fieldtype:'Float', fieldname:'available_qty', reqd: 1,
|
{fieldtype:'Float', fieldname:'available_qty',
|
||||||
label: __('Available'), in_list_view:1},
|
label: __('Available'), in_list_view:1},
|
||||||
{fieldtype:'Float', fieldname:'selected_qty', reqd: 1,
|
{fieldtype:'Float', fieldname:'selected_qty',
|
||||||
label: __('Qty'), in_list_view:1},
|
label: __('Qty'), in_list_view:1},
|
||||||
],
|
],
|
||||||
|
get_data: function() {
|
||||||
|
console.log("in get data");
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
d.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
show_modal("_Test FG Item", 1);
|
||||||
|
|
||||||
|
// frm.doc.items.forEach(function(d) {
|
||||||
|
// if(d.has_batch_no && !d.batch_no) {
|
||||||
|
// show_modal(d.item_code, d.qty);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user