From fb9ce3f37bd1aa8e62a92bddffc99d6bd203ae9e Mon Sep 17 00:00:00 2001 From: Anuja P Date: Wed, 31 Mar 2021 19:26:42 +0530 Subject: [PATCH 1/4] fix: Picked Qty conversion from Stock Qty to item Qty in DN --- erpnext/stock/doctype/pick_list/pick_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index 61b72092e7..5e529f56ae 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -346,7 +346,7 @@ def create_delivery_note(source_name, target_doc=None): if dn_item: dn_item.warehouse = location.warehouse - dn_item.qty = location.picked_qty + dn_item.qty = location.picked_qty / location.conversion_factor dn_item.batch_no = location.batch_no dn_item.serial_no = location.serial_no From a1d09320936e3b32d422e5b639994dad9c866de2 Mon Sep 17 00:00:00 2001 From: Anuja P Date: Wed, 31 Mar 2021 19:59:28 +0530 Subject: [PATCH 2/4] fix: suggested changes --- erpnext/stock/doctype/pick_list/pick_list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/pick_list/pick_list.py b/erpnext/stock/doctype/pick_list/pick_list.py index 5e529f56ae..755fa615bb 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.py +++ b/erpnext/stock/doctype/pick_list/pick_list.py @@ -346,7 +346,7 @@ def create_delivery_note(source_name, target_doc=None): if dn_item: dn_item.warehouse = location.warehouse - dn_item.qty = location.picked_qty / location.conversion_factor + dn_item.qty = flt(location.picked_qty) / (flt(location.conversion_factor) or 1) dn_item.batch_no = location.batch_no dn_item.serial_no = location.serial_no From 45d0b9bce6c8af4bdc7f1374b09984e0ac17a451 Mon Sep 17 00:00:00 2001 From: Anuja P Date: Thu, 1 Apr 2021 15:38:13 +0530 Subject: [PATCH 3/4] test: added tests for Pick List for item with multiple UOM --- .../stock/doctype/pick_list/test_pick_list.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/erpnext/stock/doctype/pick_list/test_pick_list.py b/erpnext/stock/doctype/pick_list/test_pick_list.py index 8ea7f89dc4..49ebe118ca 100644 --- a/erpnext/stock/doctype/pick_list/test_pick_list.py +++ b/erpnext/stock/doctype/pick_list/test_pick_list.py @@ -9,6 +9,7 @@ test_dependencies = ['Item', 'Sales Invoice', 'Stock Entry', 'Batch'] from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt from erpnext.stock.doctype.item.test_item import create_item +from erpnext.stock.doctype.pick_list.pick_list import create_delivery_note from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation \ import EmptyStockReconciliationItemsError @@ -291,6 +292,63 @@ class TestPickList(unittest.TestCase): 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_for_items_with_multiple_UOM(self): + purchase_receipt = make_purchase_receipt(item_code="_Test Item", qty=10) + purchase_receipt.submit() + + sales_order = frappe.get_doc({ + 'doctype': 'Sales Order', + 'customer': '_Test Customer', + 'company': '_Test Company', + 'items': [{ + 'item_code': '_Test Item', + 'qty': 1, + 'conversion_factor': 5, + 'delivery_date': frappe.utils.today() + }, + { + 'item_code': '_Test Item', + 'qty': 1, + 'conversion_factor': 1, + 'delivery_date': frappe.utils.today() + }], + }).insert() + 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', + 'qty': 1, + 'stock_qty': 5, + 'conversion_factor': 5, + 'sales_order': sales_order.name, + 'sales_order_item': sales_order.items[0].name , + }, + { + 'item_code': '_Test Item', + 'qty': 1, + 'stock_qty': 1, + 'conversion_factor': 1, + 'sales_order': sales_order.name, + 'sales_order_item': sales_order.items[1].name , + }] + }) + pick_list.set_item_locations() + pick_list.submit() + + delivery_note = create_delivery_note(pick_list.name) + + self.assertEqual(pick_list.locations[0].qty, delivery_note.items[0].qty) + self.assertEqual(pick_list.locations[1].qty, delivery_note.items[1].qty) + self.assertEqual(sales_order.items[0].conversion_factor, delivery_note.items[0].conversion_factor) + + pick_list.cancel() + sales_order.cancel() + purchase_receipt.cancel() # def test_pick_list_skips_items_in_expired_batch(self): # pass From 798268850889a888fb2d4942df0febf350e8f5ca Mon Sep 17 00:00:00 2001 From: Anuja P Date: Thu, 1 Apr 2021 16:04:28 +0530 Subject: [PATCH 4/4] fix: sider changes --- erpnext/stock/doctype/pick_list/test_pick_list.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/erpnext/stock/doctype/pick_list/test_pick_list.py b/erpnext/stock/doctype/pick_list/test_pick_list.py index 49ebe118ca..a762e9763e 100644 --- a/erpnext/stock/doctype/pick_list/test_pick_list.py +++ b/erpnext/stock/doctype/pick_list/test_pick_list.py @@ -305,8 +305,7 @@ class TestPickList(unittest.TestCase): 'qty': 1, 'conversion_factor': 5, 'delivery_date': frappe.utils.today() - }, - { + }, { 'item_code': '_Test Item', 'qty': 1, 'conversion_factor': 1, @@ -327,8 +326,7 @@ class TestPickList(unittest.TestCase): 'conversion_factor': 5, 'sales_order': sales_order.name, 'sales_order_item': sales_order.items[0].name , - }, - { + }, { 'item_code': '_Test Item', 'qty': 1, 'stock_qty': 1,