mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-14 02:04:17 +00:00
fix(manufacturing): validate delivered qty in production plan
(cherry picked from commit eda8a621c6)
This commit is contained in:
@@ -369,6 +369,15 @@ class ProductionPlan(Document):
|
|||||||
|
|
||||||
pi = frappe.qb.DocType("Packed Item")
|
pi = frappe.qb.DocType("Packed Item")
|
||||||
|
|
||||||
|
pending_qty = (
|
||||||
|
frappe.qb.terms.Case()
|
||||||
|
.when(
|
||||||
|
(so_item.work_order_qty > so_item.delivered_qty),
|
||||||
|
(((so_item.qty - so_item.work_order_qty) * pi.qty) / so_item.qty),
|
||||||
|
)
|
||||||
|
.else_(((so_item.qty - so_item.delivered_qty) * pi.qty) / so_item.qty)
|
||||||
|
)
|
||||||
|
|
||||||
packed_items_query = (
|
packed_items_query = (
|
||||||
frappe.qb.from_(so_item)
|
frappe.qb.from_(so_item)
|
||||||
.from_(pi)
|
.from_(pi)
|
||||||
@@ -376,7 +385,7 @@ class ProductionPlan(Document):
|
|||||||
pi.parent,
|
pi.parent,
|
||||||
pi.item_code,
|
pi.item_code,
|
||||||
pi.warehouse.as_("warehouse"),
|
pi.warehouse.as_("warehouse"),
|
||||||
(((so_item.qty - so_item.work_order_qty) * pi.qty) / so_item.qty).as_("pending_qty"),
|
pending_qty.as_("pending_qty"),
|
||||||
pi.parent_item,
|
pi.parent_item,
|
||||||
pi.description,
|
pi.description,
|
||||||
so_item.name,
|
so_item.name,
|
||||||
@@ -387,7 +396,16 @@ class ProductionPlan(Document):
|
|||||||
& (so_item.docstatus == 1)
|
& (so_item.docstatus == 1)
|
||||||
& (pi.parent_item == so_item.item_code)
|
& (pi.parent_item == so_item.item_code)
|
||||||
& (so_item.parent.isin(so_list))
|
& (so_item.parent.isin(so_list))
|
||||||
& (so_item.qty > so_item.work_order_qty)
|
& (
|
||||||
|
(
|
||||||
|
(so_item.work_order_qty > so_item.delivered_qty)
|
||||||
|
& (so_item.qty > so_item.work_order_qty)
|
||||||
|
)
|
||||||
|
| (
|
||||||
|
(so_item.work_order_qty <= so_item.delivered_qty)
|
||||||
|
& (so_item.qty > so_item.delivered_qty)
|
||||||
|
)
|
||||||
|
)
|
||||||
& (
|
& (
|
||||||
ExistsCriterion(
|
ExistsCriterion(
|
||||||
frappe.qb.from_(bom)
|
frappe.qb.from_(bom)
|
||||||
|
|||||||
Reference in New Issue
Block a user