PP tool: get items from SO based on item filter
This commit is contained in:
parent
3c5bc544ea
commit
844dd36ff9
@ -106,14 +106,21 @@ class ProductionPlanningTool(Document):
|
||||
msgprint(_("Please enter sales order in the above table"))
|
||||
return []
|
||||
|
||||
item_condition = ""
|
||||
if self.fg_item:
|
||||
item_condition = ' and so_item.item_code = "' + self.fg_item + '"'
|
||||
|
||||
items = frappe.db.sql("""select distinct parent, item_code, warehouse,
|
||||
(qty - ifnull(delivered_qty, 0)) as pending_qty
|
||||
from `tabSales Order Item` so_item
|
||||
where parent in (%s) and docstatus = 1 and ifnull(qty, 0) > ifnull(delivered_qty, 0)
|
||||
and exists (select * from `tabItem` item where item.name=so_item.item_code
|
||||
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes'))""" % \
|
||||
(", ".join(["%s"] * len(so_list))), tuple(so_list), as_dict=1)
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes')) %s""" % \
|
||||
(", ".join(["%s"] * len(so_list)), item_condition), tuple(so_list), as_dict=1)
|
||||
|
||||
if self.fg_item:
|
||||
item_condition = ' and pi.item_code = "' + self.fg_item + '"'
|
||||
|
||||
packed_items = frappe.db.sql("""select distinct pi.parent, pi.item_code, pi.warehouse as reserved_warhouse,
|
||||
(((so_item.qty - ifnull(so_item.delivered_qty, 0)) * pi.qty) / so_item.qty)
|
||||
@ -124,8 +131,8 @@ class ProductionPlanningTool(Document):
|
||||
and so_item.parent in (%s) and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0)
|
||||
and exists (select * from `tabItem` item where item.name=pi.item_code
|
||||
and (ifnull(item.is_pro_applicable, 'No') = 'Yes'
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes'))""" % \
|
||||
(", ".join(["%s"] * len(so_list))), tuple(so_list), as_dict=1)
|
||||
or ifnull(item.is_sub_contracted_item, 'No') = 'Yes')) %s""" % \
|
||||
(", ".join(["%s"] * len(so_list)), item_condition), tuple(so_list), as_dict=1)
|
||||
|
||||
return items + packed_items
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user