fix: Add option to select qty of finished goods Item

This commit is contained in:
Suraj Shetty 2019-08-22 09:53:44 +05:30
parent ec92486377
commit c1f25ff9e3
3 changed files with 36 additions and 15 deletions

View File

@ -36,10 +36,30 @@ frappe.ui.form.on('Pick List', {
},
work_order: (frm) => {
frm.clear_table('items');
erpnext.utils.map_current_doc({
method: 'erpnext.manufacturing.doctype.work_order.work_order.create_pick_list',
target: frm,
source_name: frm.doc.work_order
frappe.db.get_value('Work Order',
frm.doc.work_order,
['qty', 'produced_qty']
).then(data => {
let qty_data = data.message;
let max = qty_data.qty - qty_data.produced_qty;
frappe.prompt({
fieldtype: 'Float',
label: __('Qty'),
fieldname: 'qty',
description: __('Max: {0}', [max]),
default: max
}, (data) => {
frm.set_value('qty', data.qty);
if (data.qty > max) {
frappe.msgprint(__('Quantity must not be more than {0}', [max]));
return;
}
erpnext.utils.map_current_doc({
method: 'erpnext.manufacturing.doctype.work_order.work_order.create_pick_list',
target: frm,
source_name: frm.doc.work_order
});
}, __("Select Quantity"), __('Get Items'));
});
},
items_based_on: (frm) => {
@ -52,11 +72,8 @@ frappe.ui.form.on('Pick List', {
});
},
create_stock_entry(frm) {
// TODO: show dialog for qty
frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.create_stock_entry', {
'pick_list': frm.doc,
'qty': 1
}).then(stock_entry => {
frappe.model.sync(stock_entry);
frappe.set_route("Form", 'Stock Entry', stock_entry.name);

View File

@ -8,6 +8,7 @@
"items_based_on",
"customer",
"work_order",
"qty",
"column_break_4",
"parent_warehouse",
"company",
@ -59,8 +60,7 @@
"fieldtype": "Link",
"in_list_view": 1,
"label": "Customer",
"options": "Customer",
"reqd": 1
"options": "Customer"
},
{
"depends_on": "eval:doc.items_based_on===\"Work Order\"",
@ -81,9 +81,16 @@
"fieldtype": "Table",
"label": "Item Locations",
"options": "Pick List Item"
},
{
"depends_on": "work_order",
"description": "Qty of raw materials will be decided based on the qty of the Finished Goods Item",
"fieldname": "qty",
"fieldtype": "Float",
"label": "Qty of Finished Goods Item"
}
],
"modified": "2019-08-20 16:57:11.006221",
"modified": "2019-08-22 09:50:01.099449",
"modified_by": "Administrator",
"module": "Stock",
"name": "Pick List",

View File

@ -231,12 +231,9 @@ def set_delivery_note_missing_values(target):
@frappe.whitelist()
def create_stock_entry(pick_list, qty):
def create_stock_entry(pick_list):
pick_list = frappe.get_doc(json.loads(pick_list))
work_order = frappe.get_doc("Work Order", pick_list.get('work_order'))
if not qty:
qty = work_order.qty - work_order.material_transferred_for_manufacturing
if not qty: return
stock_entry = frappe.new_doc('Stock Entry')
stock_entry.purpose = 'Material Transfer For Manufacture'
@ -246,7 +243,7 @@ def create_stock_entry(pick_list, qty):
stock_entry.from_bom = 1
stock_entry.bom_no = work_order.bom_no
stock_entry.use_multi_level_bom = work_order.use_multi_level_bom
stock_entry.fg_completed_qty = (flt(work_order.qty) - flt(work_order.produced_qty))
stock_entry.fg_completed_qty = pick_list.qty
if work_order.bom_no:
stock_entry.inspection_required = frappe.db.get_value('BOM',
work_order.bom_no, 'inspection_required')