Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extra qty pick in pick list #42345

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,17 @@ def update_picking_status(self):
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):
Expand Down
31 changes: 31 additions & 0 deletions erpnext/stock/doctype/pick_list/test_pick_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,3 +1174,34 @@ def test_validate_picked_qty_with_manual_option(self):
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)
9 changes: 8 additions & 1 deletion erpnext/stock/doctype/stock_settings/stock_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -446,14 +447,20 @@
"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": "icon-cog",
"idx": 1,
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-07-04 12:45:09.811280",
"modified": "2024-07-15 17:18:23.872161",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Settings",
Expand Down
1 change: 1 addition & 0 deletions erpnext/stock/doctype/stock_settings/stock_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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
Expand Down
Loading