fix: Use purpose field and remove item_base_on field
This commit is contained in:
parent
687b1a5b1f
commit
8b4d604cfd
@ -1010,9 +1010,6 @@ def make_pick_list(source_name, target_doc=None):
|
||||
doc = get_mapped_doc("Sales Order", source_name, {
|
||||
"Sales Order": {
|
||||
"doctype": "Pick List",
|
||||
"field_map": {
|
||||
"doctype": "items_based_on"
|
||||
},
|
||||
"validation": {
|
||||
"docstatus": ["=", 1]
|
||||
}
|
||||
@ -1028,4 +1025,6 @@ def make_pick_list(source_name, target_doc=None):
|
||||
},
|
||||
}, target_doc)
|
||||
|
||||
doc.purpose = 'Delivery against Sales Order'
|
||||
|
||||
return doc
|
||||
|
@ -23,16 +23,21 @@ frappe.ui.form.on('Pick List', {
|
||||
refresh: (frm) => {
|
||||
frm.trigger('add_get_items_button');
|
||||
|
||||
if (frm.doc.items && (frm.doc.items.length > 1 || frm.doc.items[0].item_code)) {
|
||||
if (frm.doc.items && (frm.doc.items.length > 1 || frm.doc.items[0].item_code) && frm.doc.docstatus === 0) {
|
||||
frm.add_custom_button(__('Get Item Locations'), () => {
|
||||
frm.call('set_item_locations');
|
||||
}).addClass('btn-primary');
|
||||
}
|
||||
if (frm.doc.docstatus == 1) {
|
||||
if (frm.doc.items_based_on === 'Sales Order') {
|
||||
if (frm.doc.docstatus === 1) {
|
||||
if (frm.doc.purpose === 'Delivery against Sales Order') {
|
||||
frm.add_custom_button(__('Delivery Note'), () => frm.trigger('create_delivery_note'), __('Create'));
|
||||
} else {
|
||||
frm.add_custom_button(__('Stock Entry'), () => frm.trigger('create_stock_entry'), __('Create'));
|
||||
frappe.xcall('erpnext.stock.doctype.pick_list.pick_list.stock_entry_exists', {
|
||||
'pick_list_name': frm.doc.name
|
||||
}).then(exists => {
|
||||
if (exists) return;
|
||||
frm.add_custom_button(__('Stock Entry'), () => frm.trigger('create_stock_entry'), __('Create'));
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -65,7 +70,7 @@ frappe.ui.form.on('Pick List', {
|
||||
}, __("Select Quantity"), __('Get Items'));
|
||||
});
|
||||
},
|
||||
items_based_on: (frm) => {
|
||||
purpose: (frm) => {
|
||||
frm.clear_table('items');
|
||||
frm.clear_table('locations');
|
||||
frm.trigger('add_get_items_button');
|
||||
@ -85,8 +90,8 @@ frappe.ui.form.on('Pick List', {
|
||||
});
|
||||
},
|
||||
add_get_items_button(frm) {
|
||||
let source_doctype = frm.doc.items_based_on;
|
||||
if (source_doctype != 'Sales Order') return;
|
||||
let purpose = frm.doc.purpose;
|
||||
if (purpose != 'Delivery against Sales Order' || frm.doc.docstatus !== 0) return;
|
||||
let get_query_filters = {
|
||||
docstatus: 1,
|
||||
per_delivered: ['<', 100],
|
||||
|
@ -6,7 +6,6 @@
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"purpose",
|
||||
"items_based_on",
|
||||
"customer",
|
||||
"work_order",
|
||||
"for_qty",
|
||||
@ -48,16 +47,7 @@
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"default": "Work Order",
|
||||
"fieldname": "items_based_on",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Items Based On",
|
||||
"options": "Sales Order\nWork Order",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.items_based_on===\"Sales Order\"",
|
||||
"depends_on": "eval:doc.purpose==='Delivery against Sales Order'",
|
||||
"fieldname": "customer",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
@ -65,7 +55,7 @@
|
||||
"options": "Customer"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.items_based_on===\"Work Order\"",
|
||||
"depends_on": "eval:doc.purpose==='Material Transfer for Manufacture'",
|
||||
"fieldname": "work_order",
|
||||
"fieldtype": "Link",
|
||||
"label": "Work Order",
|
||||
@ -102,15 +92,15 @@
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "Material Transfer for manufacturing",
|
||||
"default": "Material Transfer for Manufacture",
|
||||
"fieldname": "purpose",
|
||||
"fieldtype": "Select",
|
||||
"label": "Purpose",
|
||||
"options": "Material Transfer for manufacturing\nMaterial Issue\nMaterial Transfer\nDelivery against Sales Order"
|
||||
"options": "Material Transfer for Manufacture\nMaterial Issue\nMaterial Transfer\nDelivery against Sales Order"
|
||||
}
|
||||
],
|
||||
"is_submittable": 1,
|
||||
"modified": "2019-08-22 13:36:18.912659",
|
||||
"modified": "2019-08-22 16:58:07.270447",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Pick List",
|
||||
|
@ -7,6 +7,7 @@ import frappe
|
||||
import json
|
||||
from six import iteritems
|
||||
from frappe.model.document import Document
|
||||
from frappe import _
|
||||
from frappe.utils import floor, flt, today
|
||||
from frappe.model.mapper import get_mapped_doc, map_child_doc
|
||||
from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note as create_delivery_note_from_sales_order
|
||||
@ -234,11 +235,14 @@ def set_delivery_note_missing_values(target):
|
||||
@frappe.whitelist()
|
||||
def create_stock_entry(pick_list):
|
||||
pick_list = frappe.get_doc(json.loads(pick_list))
|
||||
if stock_entry_exists(pick_list.get('name')):
|
||||
return frappe.msgprint(_('Stock Entry already exists against this Pick List'))
|
||||
|
||||
work_order = frappe.get_doc("Work Order", pick_list.get('work_order'))
|
||||
|
||||
stock_entry = frappe.new_doc('Stock Entry')
|
||||
stock_entry.pick_list = pick_list.get('name')
|
||||
stock_entry.purpose = 'Material Transfer For Manufacture'
|
||||
stock_entry.purpose = pick_list.get('purpose')
|
||||
stock_entry.set_stock_entry_type()
|
||||
stock_entry.work_order = work_order.name
|
||||
stock_entry.company = work_order.company
|
||||
@ -305,3 +309,9 @@ def get_pending_work_orders(doctype, txt, searchfield, start, page_length, filte
|
||||
|
||||
def get_item_details(item_code):
|
||||
pass
|
||||
|
||||
@frappe.whitelist()
|
||||
def stock_entry_exists(pick_list_name):
|
||||
return frappe.db.exists('Stock Entry', {
|
||||
'pick_list': pick_list_name
|
||||
})
|
||||
|
@ -618,7 +618,6 @@
|
||||
{
|
||||
"fieldname": "pick_list",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"label": "Pick List",
|
||||
"options": "Pick List",
|
||||
"read_only": 1
|
||||
@ -627,7 +626,7 @@
|
||||
"icon": "fa fa-file-text",
|
||||
"idx": 1,
|
||||
"is_submittable": 1,
|
||||
"modified": "2019-08-22 13:09:55.344036",
|
||||
"modified": "2019-08-22 17:11:42.074154",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Entry",
|
||||
|
Loading…
x
Reference in New Issue
Block a user