fix: Add and rename some fields
- Add ability to create delivery note from pick ticket - Minor fix related to create button
This commit is contained in:
parent
72d03464dc
commit
fa9111ebe2
@ -102,7 +102,6 @@ frappe.ui.form.on("Sales Order Item", {
|
||||
erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
|
||||
onload: function(doc, dt, dn) {
|
||||
this._super();
|
||||
this.frm.add_custom_button(__('Pick Ticket'), () => this.make_pick_ticket(), __('Create'));
|
||||
},
|
||||
|
||||
refresh: function(doc, dt, dn) {
|
||||
@ -110,7 +109,9 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
|
||||
this._super();
|
||||
let allow_delivery = false;
|
||||
|
||||
if(doc.docstatus==1) {
|
||||
if (doc.docstatus==1) {
|
||||
this.frm.add_custom_button(__('Pick Ticket'), () => this.make_pick_ticket(), __('Create'));
|
||||
|
||||
if(this.frm.has_perm("submit")) {
|
||||
if(doc.status === 'On Hold') {
|
||||
// un-hold
|
||||
|
@ -1011,7 +1011,8 @@ def make_pick_ticket(source_name, target_doc=None):
|
||||
"field_map": {
|
||||
"item_code": "item",
|
||||
"parenttype": "reference_doctype",
|
||||
"parent": "reference_name"
|
||||
"parent": "reference_name",
|
||||
"name": "reference_document_item"
|
||||
},
|
||||
},
|
||||
}, target_doc)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
frappe.ui.form.on('Pick Ticket', {
|
||||
setup: (frm) => {
|
||||
frm.set_query('group_warehouse', () => {
|
||||
frm.set_query('parent_warehouse', () => {
|
||||
return {
|
||||
filters: {
|
||||
'is_group': 1,
|
||||
@ -13,7 +13,8 @@ frappe.ui.form.on('Pick Ticket', {
|
||||
});
|
||||
},
|
||||
refresh: (frm) => {
|
||||
this.frm.add_custom_button(__('Sales Order'), function() {
|
||||
frm.add_custom_button(__('Delivery Note'), () => frm.trigger('make_delivery_note'), __('Create'));
|
||||
frm.add_custom_button(__('Sales Order'), function() {
|
||||
erpnext.utils.map_current_doc({
|
||||
method: "erpnext.selling.doctype.sales_order.sales_order.make_pick_ticket",
|
||||
source_doctype: "Sales Order",
|
||||
@ -27,11 +28,16 @@ frappe.ui.form.on('Pick Ticket', {
|
||||
});
|
||||
}, __("Get items from"));
|
||||
|
||||
if (frm.doc.reference_document_items.length) {
|
||||
if (frm.doc.reference_items && frm.doc.reference_items.length) {
|
||||
frm.add_custom_button(__('Get Item Locations'), () => {
|
||||
frm.call('set_item_locations');
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
make_delivery_note(frm) {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "erpnext.stock.doctype.pick_ticket.pick_ticket.make_delivery_note",
|
||||
frm: frm
|
||||
});
|
||||
},
|
||||
});
|
||||
|
@ -7,27 +7,13 @@
|
||||
"field_order": [
|
||||
"company",
|
||||
"column_break_4",
|
||||
"group_warehouse",
|
||||
"parent_warehouse",
|
||||
"section_break_4",
|
||||
"reference_document_items",
|
||||
"reference_items",
|
||||
"section_break_6",
|
||||
"items"
|
||||
"item_locations"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "items",
|
||||
"fieldtype": "Table",
|
||||
"label": "Items Locations",
|
||||
"options": "Pick Ticket Item",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"description": "Items under this warehouse will be suggested",
|
||||
"fieldname": "group_warehouse",
|
||||
"fieldtype": "Link",
|
||||
"label": "Group Warehouse",
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
@ -44,17 +30,29 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_4",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Reference Items"
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_document_items",
|
||||
"description": "Items under this warehouse will be suggested",
|
||||
"fieldname": "parent_warehouse",
|
||||
"fieldtype": "Link",
|
||||
"label": "Parent Warehouse",
|
||||
"options": "Warehouse"
|
||||
},
|
||||
{
|
||||
"fieldname": "item_locations",
|
||||
"fieldtype": "Table",
|
||||
"label": "Reference Document Items",
|
||||
"label": "Item Locations",
|
||||
"options": "Pick Ticket Item"
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_items",
|
||||
"fieldtype": "Table",
|
||||
"label": "Items To Be Picked",
|
||||
"options": "Pick Ticket Reference Item"
|
||||
}
|
||||
],
|
||||
"modified": "2019-07-26 12:06:08.941760",
|
||||
"modified": "2019-08-01 10:50:17.055509",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Pick Ticket",
|
||||
|
@ -5,23 +5,24 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
class PickTicket(Document):
|
||||
def set_item_locations(self):
|
||||
reference_items = self.reference_document_items
|
||||
reference_items = self.reference_items
|
||||
|
||||
from_warehouses = None
|
||||
if self.group_warehouse:
|
||||
from_warehouses = frappe.db.get_descendants('Warehouse', self.group_warehouse)
|
||||
if self.parent_warehouse:
|
||||
from_warehouses = frappe.db.get_descendants('Warehouse', self.parent_warehouse)
|
||||
|
||||
# Reset
|
||||
self.delete_key('items')
|
||||
self.delete_key('item_locations')
|
||||
for item in reference_items:
|
||||
data = get_items_with_warehouse_and_quantity(item, from_warehouses)
|
||||
for item_info in data:
|
||||
print(self.append('items', item_info))
|
||||
print(self.append('item_locations', item_info))
|
||||
|
||||
for item_doc in self.get('items'):
|
||||
for item_doc in self.get('item_locations'):
|
||||
if frappe.get_cached_value('Item', item_doc.item, 'has_serial_no'):
|
||||
set_serial_nos(item_doc)
|
||||
elif frappe.get_cached_value('Item', item_doc.item, 'has_batch_no'):
|
||||
@ -40,7 +41,8 @@ def get_items_with_warehouse_and_quantity(item_doc, from_warehouses):
|
||||
'qty': qty,
|
||||
'warehouse': item_location.warehouse,
|
||||
'reference_doctype': item_doc.reference_doctype,
|
||||
'reference_name': item_doc.reference_name
|
||||
'reference_name': item_doc.reference_name,
|
||||
'reference_document_item': item_doc.reference_document_item,
|
||||
})
|
||||
remaining_qty -= qty
|
||||
|
||||
@ -120,8 +122,29 @@ def set_batch_no(item_doc, parent_doc):
|
||||
'qty': required_qty,
|
||||
'warehouse': item_doc.warehouse,
|
||||
'reference_doctype': item_doc.reference_doctype,
|
||||
'reference_name': item_doc.reference_name
|
||||
'reference_name': item_doc.reference_name,
|
||||
'reference_document_item': item_doc.reference_document_item,
|
||||
})
|
||||
if required_qty:
|
||||
frappe.msgprint('No batches found for {} qty of {}. Skipping...'.format(required_qty, item_doc.item))
|
||||
parent_doc.remove(item_doc)
|
||||
|
||||
@frappe.whitelist()
|
||||
def make_delivery_note(source_name, target_doc=None):
|
||||
target_doc = get_mapped_doc("Pick Ticket", source_name, {
|
||||
"Pick Ticket": {
|
||||
"doctype": "Delivery Note",
|
||||
# "validation": {
|
||||
# "docstatus": ["=", 1]
|
||||
# }
|
||||
},
|
||||
"Pick Ticket Item": {
|
||||
"doctype": "Delivery Note Item",
|
||||
"field_map": {
|
||||
"item": "item_code",
|
||||
"reference_docname": "against_sales_order",
|
||||
},
|
||||
},
|
||||
}, target_doc)
|
||||
|
||||
return target_doc
|
@ -14,7 +14,7 @@ class TestPickTicket(unittest.TestCase):
|
||||
pick_ticket = frappe.get_doc({
|
||||
'doctype': 'Pick Ticket',
|
||||
'company': '_Test Company',
|
||||
'reference_document_items': [{
|
||||
'reference_items': [{
|
||||
'item': '_Test Item Home Desktop 100',
|
||||
'reference_doctype': 'Sales Order',
|
||||
'qty': 5,
|
||||
@ -24,15 +24,15 @@ class TestPickTicket(unittest.TestCase):
|
||||
|
||||
pick_ticket.set_item_locations()
|
||||
|
||||
self.assertEqual(pick_ticket.items[0].item, '_Test Item Home Desktop 100')
|
||||
self.assertEqual(pick_ticket.items[0].warehouse, '_Test Warehouse - _TC')
|
||||
self.assertEqual(pick_ticket.items[0].qty, 5)
|
||||
self.assertEqual(pick_ticket.items_locations[0].item, '_Test Item Home Desktop 100')
|
||||
self.assertEqual(pick_ticket.items_locations[0].warehouse, '_Test Warehouse - _TC')
|
||||
self.assertEqual(pick_ticket.items_locations[0].qty, 5)
|
||||
|
||||
def test_pick_ticket_skips_out_of_stock_item(self):
|
||||
pick_ticket = frappe.get_doc({
|
||||
'doctype': 'Pick Ticket',
|
||||
'company': '_Test Company',
|
||||
'reference_document_items': [{
|
||||
'reference_items': [{
|
||||
'item': '_Test Item Warehouse Group Wise Reorder',
|
||||
'reference_doctype': 'Sales Order',
|
||||
'qty': 1000,
|
||||
@ -42,9 +42,9 @@ class TestPickTicket(unittest.TestCase):
|
||||
|
||||
pick_ticket.set_item_locations()
|
||||
|
||||
self.assertEqual(pick_ticket.items[0].item, '_Test Item Warehouse Group Wise Reorder')
|
||||
self.assertEqual(pick_ticket.items[0].warehouse, '_Test Warehouse Group-C1 - _TC')
|
||||
self.assertEqual(pick_ticket.items[0].qty, 30)
|
||||
self.assertEqual(pick_ticket.items_locations[0].item, '_Test Item Warehouse Group Wise Reorder')
|
||||
self.assertEqual(pick_ticket.items_locations[0].warehouse, '_Test Warehouse Group-C1 - _TC')
|
||||
self.assertEqual(pick_ticket.items_locations[0].qty, 30)
|
||||
|
||||
|
||||
def test_pick_ticket_skips_items_in_expired_batch(self):
|
||||
@ -68,7 +68,7 @@ class TestPickTicket(unittest.TestCase):
|
||||
pick_ticket = frappe.get_doc({
|
||||
'doctype': 'Pick Ticket',
|
||||
'company': '_Test Company',
|
||||
'reference_document_items': [{
|
||||
'reference_items': [{
|
||||
'item': '_Test Serialized Item',
|
||||
'reference_doctype': 'Sales Order',
|
||||
'qty': 1000,
|
||||
@ -77,26 +77,16 @@ class TestPickTicket(unittest.TestCase):
|
||||
})
|
||||
|
||||
pick_ticket.set_item_locations()
|
||||
self.assertEqual(pick_ticket.items[0].item, '_Test Serialized Item')
|
||||
self.assertEqual(pick_ticket.items[0].warehouse, '_Test Warehouse Group-C1 - _TC')
|
||||
self.assertEqual(pick_ticket.items[0].qty, 30)
|
||||
self.assertEqual(pick_ticket.items[0].serial_no, 30)
|
||||
self.assertEqual(pick_ticket.items_locations[0].item, '_Test Serialized Item')
|
||||
self.assertEqual(pick_ticket.items_locations[0].warehouse, '_Test Warehouse Group-C1 - _TC')
|
||||
self.assertEqual(pick_ticket.items_locations[0].qty, 30)
|
||||
self.assertEqual(pick_ticket.items_locations[0].serial_no, 30)
|
||||
|
||||
|
||||
def test_pick_ticket_for_multiple_reference_doctypes(self):
|
||||
pass
|
||||
|
||||
|
||||
# def create_new_pick_ticket():
|
||||
# pass
|
||||
# doc = frappe.new_doc('Pick Ticket')
|
||||
# doc.items.append({
|
||||
# 'item': '_Test Warehouse - _TC',
|
||||
# ''
|
||||
# })
|
||||
|
||||
|
||||
|
||||
## records required
|
||||
|
||||
'''
|
||||
|
@ -68,7 +68,6 @@
|
||||
{
|
||||
"fieldname": "reference_document_item",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
"label": "Reference Document Item",
|
||||
"read_only": 1
|
||||
},
|
||||
@ -130,7 +129,7 @@
|
||||
}
|
||||
],
|
||||
"istable": 1,
|
||||
"modified": "2019-07-30 09:28:44.969479",
|
||||
"modified": "2019-07-30 23:47:53.566473",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Pick Ticket Item",
|
||||
|
@ -7,7 +7,8 @@
|
||||
"item",
|
||||
"qty",
|
||||
"reference_doctype",
|
||||
"reference_name"
|
||||
"reference_name",
|
||||
"reference_document_item"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@ -34,10 +35,15 @@
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Qty"
|
||||
},
|
||||
{
|
||||
"fieldname": "reference_document_item",
|
||||
"fieldtype": "Data",
|
||||
"label": "Reference Document Item"
|
||||
}
|
||||
],
|
||||
"istable": 1,
|
||||
"modified": "2019-07-26 12:17:52.142186",
|
||||
"modified": "2019-07-30 23:43:30.901151",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Pick Ticket Reference Item",
|
||||
|
Loading…
Reference in New Issue
Block a user