fix: Add option to select qty of finished goods Item
This commit is contained in:
parent
ec92486377
commit
c1f25ff9e3
@ -36,10 +36,30 @@ frappe.ui.form.on('Pick List', {
|
|||||||
},
|
},
|
||||||
work_order: (frm) => {
|
work_order: (frm) => {
|
||||||
frm.clear_table('items');
|
frm.clear_table('items');
|
||||||
erpnext.utils.map_current_doc({
|
frappe.db.get_value('Work Order',
|
||||||
method: 'erpnext.manufacturing.doctype.work_order.work_order.create_pick_list',
|
frm.doc.work_order,
|
||||||
target: frm,
|
['qty', 'produced_qty']
|
||||||
source_name: frm.doc.work_order
|
).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) => {
|
items_based_on: (frm) => {
|
||||||
@ -52,11 +72,8 @@ frappe.ui.form.on('Pick List', {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
create_stock_entry(frm) {
|
create_stock_entry(frm) {
|
||||||
// TODO: show dialog for qty
|
|
||||||
|
|
||||||
frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.create_stock_entry', {
|
frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.create_stock_entry', {
|
||||||
'pick_list': frm.doc,
|
'pick_list': frm.doc,
|
||||||
'qty': 1
|
|
||||||
}).then(stock_entry => {
|
}).then(stock_entry => {
|
||||||
frappe.model.sync(stock_entry);
|
frappe.model.sync(stock_entry);
|
||||||
frappe.set_route("Form", 'Stock Entry', stock_entry.name);
|
frappe.set_route("Form", 'Stock Entry', stock_entry.name);
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
"items_based_on",
|
"items_based_on",
|
||||||
"customer",
|
"customer",
|
||||||
"work_order",
|
"work_order",
|
||||||
|
"qty",
|
||||||
"column_break_4",
|
"column_break_4",
|
||||||
"parent_warehouse",
|
"parent_warehouse",
|
||||||
"company",
|
"company",
|
||||||
@ -59,8 +60,7 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Customer",
|
"label": "Customer",
|
||||||
"options": "Customer",
|
"options": "Customer"
|
||||||
"reqd": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"depends_on": "eval:doc.items_based_on===\"Work Order\"",
|
"depends_on": "eval:doc.items_based_on===\"Work Order\"",
|
||||||
@ -81,9 +81,16 @@
|
|||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"label": "Item Locations",
|
"label": "Item Locations",
|
||||||
"options": "Pick List Item"
|
"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",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Pick List",
|
"name": "Pick List",
|
||||||
|
@ -231,12 +231,9 @@ def set_delivery_note_missing_values(target):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_stock_entry(pick_list, qty):
|
def create_stock_entry(pick_list):
|
||||||
pick_list = frappe.get_doc(json.loads(pick_list))
|
pick_list = frappe.get_doc(json.loads(pick_list))
|
||||||
work_order = frappe.get_doc("Work Order", pick_list.get('work_order'))
|
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 = frappe.new_doc('Stock Entry')
|
||||||
stock_entry.purpose = 'Material Transfer For Manufacture'
|
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.from_bom = 1
|
||||||
stock_entry.bom_no = work_order.bom_no
|
stock_entry.bom_no = work_order.bom_no
|
||||||
stock_entry.use_multi_level_bom = work_order.use_multi_level_bom
|
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:
|
if work_order.bom_no:
|
||||||
stock_entry.inspection_required = frappe.db.get_value('BOM',
|
stock_entry.inspection_required = frappe.db.get_value('BOM',
|
||||||
work_order.bom_no, 'inspection_required')
|
work_order.bom_no, 'inspection_required')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user