fix: Add option to get items from work order
This commit is contained in:
parent
a7dc3735ae
commit
b35c0410b1
@ -161,6 +161,10 @@ frappe.ui.form.on("Work Order", {
|
||||
frm.add_custom_button(__('Create BOM'), () => {
|
||||
frm.trigger("make_bom");
|
||||
});
|
||||
|
||||
frm.add_custom_button(__('Pick List'), () => {
|
||||
frm.trigger("make_bom");
|
||||
}, __('Make'));
|
||||
}
|
||||
},
|
||||
|
||||
@ -264,6 +268,10 @@ frappe.ui.form.on("Work Order", {
|
||||
});
|
||||
},
|
||||
|
||||
make_pick_list() {
|
||||
|
||||
},
|
||||
|
||||
show_progress: function(frm) {
|
||||
var bars = [];
|
||||
var message = '';
|
||||
|
@ -19,6 +19,7 @@ from erpnext.stock.stock_balance import get_planned_qty, update_bin_qty
|
||||
from frappe.utils.csvutils import getlink
|
||||
from erpnext.stock.utils import get_bin, validate_warehouse_company, get_latest_stock_qty
|
||||
from erpnext.utilities.transaction_base import validate_uom_is_integer
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
class OverProductionError(frappe.ValidationError): pass
|
||||
class StockOverProductionError(frappe.ValidationError): pass
|
||||
@ -707,3 +708,26 @@ def get_work_order_operation_data(work_order, operation, workstation):
|
||||
for d in work_order.operations:
|
||||
if d.operation == operation and d.workstation == workstation:
|
||||
return d
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_pick_list(source_name, target_doc=None):
|
||||
doc = get_mapped_doc("Work Order", source_name, {
|
||||
"Work Order": {
|
||||
"doctype": "Pick List",
|
||||
"validation": {
|
||||
"docstatus": ["=", 1]
|
||||
}
|
||||
},
|
||||
"Work Order Item": {
|
||||
"doctype": "Pick List Reference Item",
|
||||
"field_map": {
|
||||
"item_code": "item",
|
||||
"required_qty": "qty",
|
||||
"parenttype": "reference_doctype",
|
||||
"parent": "reference_name",
|
||||
"name": "reference_document_item"
|
||||
},
|
||||
},
|
||||
}, target_doc)
|
||||
|
||||
return doc
|
||||
|
@ -14,13 +14,13 @@ frappe.ui.form.on('Pick List', {
|
||||
},
|
||||
refresh: (frm) => {
|
||||
frm.add_custom_button(__('Delivery Note'), () => frm.trigger('make_delivery_note'), __('Create'));
|
||||
frm.add_custom_button(__('Sales Order'), function() {
|
||||
frm.add_custom_button(__('Sales Order'), () => {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_pick_list",
|
||||
source_doctype: "Sales Order",
|
||||
target: frm,
|
||||
setters: {
|
||||
company: frm.doc.company || undefined,
|
||||
company: frm.doc.company,
|
||||
},
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
@ -28,6 +28,21 @@ frappe.ui.form.on('Pick List', {
|
||||
});
|
||||
}, __("Get items from"));
|
||||
|
||||
frm.add_custom_button(__('Work Order'), () => {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.manufacturing.doctype.work_order.work_order.make_pick_list",
|
||||
source_doctype: "Work Order",
|
||||
target: frm,
|
||||
setters: {
|
||||
company: frm.doc.company,
|
||||
},
|
||||
date_field: 'creation',
|
||||
get_query_filters: {
|
||||
docstatus: 1,
|
||||
}
|
||||
});
|
||||
}, __("Get items from"));
|
||||
|
||||
if (frm.doc.reference_items && frm.doc.reference_items.length) {
|
||||
frm.add_custom_button(__('Get Item Locations'), () => {
|
||||
frm.call('set_item_locations');
|
||||
|
@ -97,7 +97,6 @@ def set_batch_no(item_doc, parent_doc):
|
||||
'item_code': item_doc.item,
|
||||
'warehouse': item_doc.warehouse,
|
||||
}, as_dict=1)
|
||||
print(batches)
|
||||
|
||||
required_qty = item_doc.qty
|
||||
while required_qty > 0 and batches:
|
||||
@ -114,8 +113,8 @@ def set_batch_no(item_doc, parent_doc):
|
||||
# split item if quantity of item in batch is less that required
|
||||
# Look for another batch
|
||||
|
||||
# set quantity of of item equal to batch quantity
|
||||
required_qty -= batch.qty
|
||||
# set quantity of current item equal to batch quantity
|
||||
item_doc.set('qty', batch.qty)
|
||||
item_doc = parent_doc.append('items', {
|
||||
'item': item_doc.item,
|
||||
|
Loading…
x
Reference in New Issue
Block a user