diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py index 3648d6edd7d87cc5e27b380ff69dd2973f0d2fbd..7a848891c00d8aab23e72ad5dd7b9c5c7b29ca43 100755 --- a/erpnext/selling/doctype/sales_order/sales_order.py +++ b/erpnext/selling/doctype/sales_order/sales_order.py @@ -624,6 +624,17 @@ class SalesOrder(SellingController): if total_picked_qty and total_qty: per_picked = total_picked_qty / total_qty * 100 + pick_percentage = frappe.db.get_single_value("Stock Settings", "over_picking_allowance") + if pick_percentage: + total_qty += flt(total_qty) * (pick_percentage / 100) + + if total_picked_qty > total_qty: + frappe.throw( + _( + "Total Picked Quantity {0} is more than ordered qty {1}. You can set the Over Picking Allowance in Stock Settings." + ).format(total_picked_qty, total_qty) + ) + self.db_set("per_picked", flt(per_picked), update_modified=False) def set_indicator(self): diff --git a/erpnext/stock/doctype/pick_list/test_pick_list.py b/erpnext/stock/doctype/pick_list/test_pick_list.py index 91439cb3aa947b76248df42aca23bbd3d50c1384..eb196772fb57991f7fbe42cdd66955a0b17b8d51 100644 --- a/erpnext/stock/doctype/pick_list/test_pick_list.py +++ b/erpnext/stock/doctype/pick_list/test_pick_list.py @@ -1177,3 +1177,34 @@ class TestPickList(FrappeTestCase): row.qty = row.qty + 10 self.assertRaises(frappe.ValidationError, pl.save) + + def test_over_allowance_picking(self): + warehouse = "_Test Warehouse - _TC" + item = make_item( + "Test Over Allowance Picking Item", + properties={ + "is_stock_item": 1, + }, + ).name + + make_stock_entry(item=item, to_warehouse=warehouse, qty=100) + + so = make_sales_order(item_code=item, qty=10, rate=100) + + pl_doc = create_pick_list(so.name) + pl_doc.save() + self.assertEqual(pl_doc.locations[0].qty, 10) + + pl_doc.locations[0].qty = 15 + pl_doc.locations[0].stock_qty = 15 + pl_doc.save() + + self.assertEqual(pl_doc.locations[0].qty, 15) + self.assertRaises(frappe.ValidationError, pl_doc.submit) + + frappe.db.set_single_value("Stock Settings", "over_picking_allowance", 50) + + pl_doc.reload() + pl_doc.submit() + + frappe.db.set_single_value("Stock Settings", "over_picking_allowance", 0) diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json index 95ab885ba11aedaa1398365e38451ad84ab0e47d..e7abe29027347ffcdfa41e6538ddb9401e0e5138 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.json +++ b/erpnext/stock/doctype/stock_settings/stock_settings.json @@ -26,6 +26,7 @@ "section_break_9", "over_delivery_receipt_allowance", "mr_qty_allowance", + "over_picking_allowance", "column_break_121", "role_allowed_to_over_deliver_receive", "allow_negative_stock", @@ -437,6 +438,20 @@ "fieldname": "do_not_update_serial_batch_on_creation_of_auto_bundle", "fieldtype": "Check", "label": "Do Not Update Serial / Batch on Creation of Auto Bundle" + }, + { + "default": "0", + "depends_on": "eval:doc.valuation_method === \"Moving Average\"", + "description": "If enabled, the system will use the moving average valuation method to calculate the valuation rate for the batched items and will not consider the individual batch-wise incoming rate.", + "fieldname": "do_not_use_batchwise_valuation", + "fieldtype": "Check", + "label": "Do Not Use Batch-wise Valuation" + }, + { + "description": "The percentage you are allowed to pick more items in the pick list than the ordered quantity.", + "fieldname": "over_picking_allowance", + "fieldtype": "Percent", + "label": "Over Picking Allowance" } ], "icon": "uil uil-setting", @@ -444,7 +459,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2024-02-25 16:32:01.084453", + "modified": "2024-07-15 17:18:23.872161", "modified_by": "Administrator", "module": "Stock", "name": "Stock Settings", diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py index 1572ad5bba4f29955b141e119f4d0c41d78102cd..7a19d24f8732cb7ff29fc587e74a44f1e978bede 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/stock_settings.py @@ -45,6 +45,7 @@ class StockSettings(Document): mr_qty_allowance: DF.Float naming_series_prefix: DF.Data | None over_delivery_receipt_allowance: DF.Float + over_picking_allowance: DF.Percent pick_serial_and_batch_based_on: DF.Literal["FIFO", "LIFO", "Expiry"] reorder_email_notify: DF.Check role_allowed_to_create_edit_back_dated_transactions: DF.Link | None