[fix] Get open SO in production planning tool
This commit is contained in:
parent
ba9dbb1b09
commit
541927d58a
@ -44,31 +44,35 @@ class ProductionPlanningTool(Document):
|
|||||||
""" Pull sales orders which are pending to deliver based on criteria selected"""
|
""" Pull sales orders which are pending to deliver based on criteria selected"""
|
||||||
so_filter = item_filter = ""
|
so_filter = item_filter = ""
|
||||||
if self.from_date:
|
if self.from_date:
|
||||||
so_filter += ' and so.transaction_date >= "' + self.from_date + '"'
|
so_filter += " and so.transaction_date >= %(from_date)s"
|
||||||
if self.to_date:
|
if self.to_date:
|
||||||
so_filter += ' and so.transaction_date <= "' + self.to_date + '"'
|
so_filter += " and so.transaction_date <= %(to_date)s"
|
||||||
if self.customer:
|
if self.customer:
|
||||||
so_filter += ' and so.customer = "' + self.customer + '"'
|
so_filter += " and so.customer = %(customer)s"
|
||||||
|
|
||||||
if self.fg_item:
|
if self.fg_item:
|
||||||
item_filter += ' and item.name = "' + self.fg_item + '"'
|
item_filter += " and item.name = %(item)s"
|
||||||
|
|
||||||
open_so = frappe.db.sql("""
|
open_so = frappe.db.sql("""
|
||||||
select distinct so.name, so.transaction_date, so.customer, so.base_grand_total
|
select distinct so.name, so.transaction_date, so.customer, so.base_grand_total
|
||||||
from `tabSales Order` so, `tabSales Order Item` so_item
|
from `tabSales Order` so, `tabSales Order Item` so_item
|
||||||
where so_item.parent = so.name
|
where so_item.parent = so.name
|
||||||
and so.docstatus = 1 and so.status != "Stopped"
|
and so.docstatus = 1 and so.status != "Stopped"
|
||||||
and so.company = %s
|
and so.company = %(company)s
|
||||||
and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0) %s
|
and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0) {0}
|
||||||
and (exists (select name from `tabItem` item where item.name=so_item.item_code
|
and (exists (select name from `tabItem` item where item.name=so_item.item_code
|
||||||
and (item.is_pro_applicable = 1
|
and (item.is_pro_applicable = 1 or item.is_sub_contracted_item = 1 {1}))
|
||||||
or item.is_sub_contracted_item = 1 %s)
|
|
||||||
or exists (select name from `tabPacked Item` pi
|
or exists (select name from `tabPacked Item` pi
|
||||||
where pi.parent = so.name and pi.parent_item = so_item.item_code
|
where pi.parent = so.name and pi.parent_item = so_item.item_code
|
||||||
and exists (select name from `tabItem` item where item.name=pi.item_code
|
and exists (select name from `tabItem` item where item.name=pi.item_code
|
||||||
and (item.is_pro_applicable = 1
|
and (item.is_pro_applicable = 1 or item.is_sub_contracted_item = 1) {2})))
|
||||||
or item.is_sub_contracted_item = 1) %s)))
|
""".format(so_filter, item_filter, item_filter), {
|
||||||
""" % ('%s', so_filter, item_filter, item_filter), self.company, as_dict=1)
|
"from_date": self.from_date,
|
||||||
|
"to_date": self.to_date,
|
||||||
|
"customer": self.customer,
|
||||||
|
"item": self.fg_item,
|
||||||
|
"company": self.company
|
||||||
|
}, as_dict=1)
|
||||||
|
|
||||||
self.add_so_in_table(open_so)
|
self.add_so_in_table(open_so)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user