mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 03:29:16 +00:00
Filters added
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
# License: GNU General Public License v3. See license.txt
|
# License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe, json
|
||||||
|
|
||||||
from frappe.utils import flt, nowdate
|
from frappe.utils import flt, nowdate
|
||||||
from frappe import _
|
from frappe import _
|
||||||
@@ -183,16 +183,24 @@ def make_stock_entry(production_order_id, purpose, qty=None):
|
|||||||
return stock_entry.as_dict()
|
return stock_entry.as_dict()
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_events(start, end):
|
def get_events(start, end, filters=None):
|
||||||
from frappe.desk.reportview import build_match_conditions
|
from frappe.desk.reportview import build_match_conditions
|
||||||
if not frappe.has_permission("Production Order"):
|
if not frappe.has_permission("Production Order"):
|
||||||
frappe.msgprint(_("No Permission"), raise_exception=1)
|
frappe.msgprint(_("No Permission"), raise_exception=1)
|
||||||
|
|
||||||
|
conditions = build_match_conditions("Production Order")
|
||||||
|
conditions = conditions and (" and " + conditions) or ""
|
||||||
|
if filters:
|
||||||
|
filters = json.loads(filters)
|
||||||
|
for key in filters:
|
||||||
|
if filters[key]:
|
||||||
|
conditions += " and " + key + ' = "' + filters[key].replace('"', '\"') + '"'
|
||||||
|
|
||||||
data = frappe.db.sql("""select name,production_item, start_date,end_date from `tabProduction Order`
|
data = frappe.db.sql("""select name,production_item, start_date,end_date from `tabProduction Order`
|
||||||
where ((ifnull(start_date, '0000-00-00')!= '0000-00-00') \
|
where ((ifnull(start_date, '0000-00-00')!= '0000-00-00') \
|
||||||
and (start_date between %(start)s and %(end)s) \
|
and (start_date between %(start)s and %(end)s) \
|
||||||
or ((ifnull(start_date, '0000-00-00')!= '0000-00-00') \
|
or ((ifnull(start_date, '0000-00-00')!= '0000-00-00') \
|
||||||
and end_date between %(start)s and %(end)s))""", {
|
and end_date between %(start)s and %(end)s)){conditions}""".format(conditions=conditions), {
|
||||||
"start": start,
|
"start": start,
|
||||||
"end": end
|
"end": end
|
||||||
}, as_dict=True, update={"allDay": 0})
|
}, as_dict=True, update={"allDay": 0})
|
||||||
|
|||||||
@@ -10,5 +10,25 @@ frappe.views.calendar["Production Order"] = {
|
|||||||
"allDay": "allDay"
|
"allDay": "allDay"
|
||||||
},
|
},
|
||||||
gantt: true,
|
gantt: true,
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"fieldname": "sales_order",
|
||||||
|
"options": "Sales Order",
|
||||||
|
"label": __("Sales Order")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"fieldname": "production_item",
|
||||||
|
"options": "Item",
|
||||||
|
"label": __("Production Item")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"fieldname": "wip_warehouse",
|
||||||
|
"options": "Warehouse",
|
||||||
|
"label": __("WIP Warehouse")
|
||||||
|
}
|
||||||
|
],
|
||||||
get_events_method: "erpnext.manufacturing.doctype.production_order.production_order.get_events"
|
get_events_method: "erpnext.manufacturing.doctype.production_order.production_order.get_events"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user