From 72bea0dff4d7552c20ee200a8d0ce248880589a8 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 31 Aug 2019 18:34:25 +0530 Subject: [PATCH] test: Add test to check creation of pick list from multiple sales order --- .../stock/doctype/pick_list/test_pick_list.py | 70 +++++++++++++++++-- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/erpnext/stock/doctype/pick_list/test_pick_list.py b/erpnext/stock/doctype/pick_list/test_pick_list.py index d32e345047..6b4f73b140 100644 --- a/erpnext/stock/doctype/pick_list/test_pick_list.py +++ b/erpnext/stock/doctype/pick_list/test_pick_list.py @@ -40,7 +40,7 @@ class TestPickList(unittest.TestCase): 'stock_qty': 5, 'conversion_factor': 1, 'sales_order': '_T-Sales Order-1', - 'sales_item': '_T-Sales Order-1_item', + 'sales_order_item': '_T-Sales Order-1_item', }] }) pick_list.set_item_locations() @@ -93,7 +93,7 @@ class TestPickList(unittest.TestCase): 'stock_qty': 1000, 'conversion_factor': 1, 'sales_order': '_T-Sales Order-1', - 'sales_item': '_T-Sales Order-1_item', + 'sales_order_item': '_T-Sales Order-1_item', }] }) @@ -134,7 +134,7 @@ class TestPickList(unittest.TestCase): 'stock_qty': 1000, 'conversion_factor': 1, 'sales_order': '_T-Sales Order-1', - 'sales_item': '_T-Sales Order-1_item', + 'sales_order_item': '_T-Sales Order-1_item', }] }) @@ -144,8 +144,68 @@ class TestPickList(unittest.TestCase): self.assertEqual(pick_list.locations[0].qty, 5) self.assertEqual(pick_list.locations[0].serial_no, '123450\n123451\n123452\n123453\n123454') - # def test_pick_list_for_multiple_reference_doctypes(self): - # pass + def test_pick_list_for_items_from_multiple_sales_orders(self): + try: + frappe.get_doc({ + 'doctype': 'Stock Reconciliation', + 'company': '_Test Company', + 'purpose': 'Opening Stock', + 'expense_account': 'Temporary Opening - _TC', + 'items': [{ + 'item_code': '_Test Item Home Desktop 100', + 'warehouse': '_Test Warehouse - _TC', + 'valuation_rate': 100, + 'qty': 10 + }] + }).submit() + except EmptyStockReconciliationItemsError: + pass + + sales_order = frappe.get_doc({ + 'doctype': "Sales Order", + 'customer': '_Test Customer', + 'company': '_Test Company', + 'items': [{ + 'item_code': '_Test Item Home Desktop 100', + 'qty': 10, + 'delivery_date': frappe.utils.today() + }], + }) + sales_order.submit() + + pick_list = frappe.get_doc({ + 'doctype': 'Pick List', + 'company': '_Test Company', + 'customer': '_Test Customer', + 'items_based_on': 'Sales Order', + 'locations': [{ + 'item_code': '_Test Item Home Desktop 100', + 'qty': 5, + 'stock_qty': 5, + 'conversion_factor': 1, + 'sales_order': '_T-Sales Order-1', + 'sales_order_item': '_T-Sales Order-1_item', + }, { + 'item_code': '_Test Item Home Desktop 100', + 'qty': 5, + 'stock_qty': 5, + 'conversion_factor': 1, + 'sales_order': sales_order.name, + 'sales_order_item': sales_order.items[0].name, + }] + }) + pick_list.set_item_locations() + + self.assertEqual(pick_list.locations[0].item_code, '_Test Item Home Desktop 100') + self.assertEqual(pick_list.locations[0].warehouse, '_Test Warehouse - _TC') + self.assertEqual(pick_list.locations[0].qty, 5) + self.assertEqual(pick_list.locations[0].sales_order_item, '_T-Sales Order-1_item') + + self.assertEqual(pick_list.locations[1].item_code, '_Test Item Home Desktop 100') + self.assertEqual(pick_list.locations[1].warehouse, '_Test Warehouse - _TC') + self.assertEqual(pick_list.locations[1].qty, 5) + self.assertEqual(pick_list.locations[1].sales_order_item, sales_order.items[0].name) + # def test_pick_list_skips_items_in_expired_batch(self): # pass