Skip to content

Commit

Permalink
fix: dont map picked qty and consider pick qty for new PL
Browse files Browse the repository at this point in the history
Co-Authored-By: marination <maricadsouza221197@gmail.com>
  • Loading branch information
ankush and marination committed Apr 27, 2022
1 parent 8207697 commit 47e1a01
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,14 +1245,18 @@ def create_pick_list(source_name, target_doc=None):
from erpnext.stock.doctype.packed_item.packed_item import is_product_bundle

def update_item_quantity(source, target, source_parent) -> None:
target.qty = flt(source.qty) - flt(source.delivered_qty)
target.stock_qty = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.conversion_factor)
picked_qty = flt(source.picked_qty) / (flt(source.conversion_factor) or 1)
qty_to_be_picked = flt(source.qty) - max(picked_qty, flt(source.delivered_qty))

target.qty = qty_to_be_picked
target.stock_qty = qty_to_be_picked * flt(source.conversion_factor)

def update_packed_item_qty(source, target, source_parent) -> None:
qty = flt(source.qty)
for item in source_parent.items:
if source.parent_detail_docname == item.name:
pending_percent = (item.qty - item.delivered_qty) / item.qty
picked_qty = flt(item.picked_qty) / (flt(item.conversion_factor) or 1)
pending_percent = (item.qty - max(picked_qty, item.delivered_qty)) / item.qty
target.qty = target.stock_qty = qty * pending_percent
return

Expand Down Expand Up @@ -1281,6 +1285,7 @@ def should_pick_order_item(item) -> bool:
"name": "sales_order_item",
"parent_detail_docname": "product_bundle_item",
},
"field_no_map": ["picked_qty"],
"postprocess": update_packed_item_qty,
},
},
Expand Down

0 comments on commit 47e1a01

Please sign in to comment.