[enhancement] calendar for sales order and other related fixes #3542
This commit is contained in:
1
erpnext/change_log/current/calendar_for_sales_order.md
Normal file
1
erpnext/change_log/current/calendar_for_sales_order.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Added Calendar and Gantt Views for Sales Order based on Delivery Date
|
||||||
@@ -51,7 +51,7 @@ my_account_context = "erpnext.shopping_cart.utils.update_my_account_context"
|
|||||||
|
|
||||||
email_append_to = ["Job Applicant", "Opportunity", "Issue"]
|
email_append_to = ["Job Applicant", "Opportunity", "Issue"]
|
||||||
|
|
||||||
calendars = ["Task", "Production Order", "Time Log", "Leave Application"]
|
calendars = ["Task", "Production Order", "Time Log", "Leave Application", "Sales Order"]
|
||||||
|
|
||||||
website_generators = ["Item Group", "Item", "Sales Partner"]
|
website_generators = ["Item Group", "Item", "Sales Partner"]
|
||||||
|
|
||||||
|
|||||||
@@ -381,19 +381,17 @@ def make_stock_entry(production_order_id, purpose, qty=None):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_events(start, end, filters=None):
|
def get_events(start, end, filters=None):
|
||||||
from frappe.desk.reportview import build_match_conditions
|
"""Returns events for Gantt / Calendar view rendering.
|
||||||
if not frappe.has_permission("Production Order"):
|
|
||||||
frappe.msgprint(_("No Permission"), raise_exception=1)
|
|
||||||
|
|
||||||
conditions = build_match_conditions("Production Order")
|
:param start: Start date-time.
|
||||||
conditions = conditions and (" and " + conditions) or ""
|
:param end: End date-time.
|
||||||
if filters:
|
:param filters: Filters (JSON).
|
||||||
filters = json.loads(filters)
|
"""
|
||||||
for key in filters:
|
from frappe.desk.calendar import get_event_conditions
|
||||||
if filters[key]:
|
conditions = get_event_conditions("Production Order", filters)
|
||||||
conditions += " and " + key + ' = "' + filters[key].replace('"', '\"') + '"'
|
|
||||||
|
|
||||||
data = frappe.db.sql("""select name, production_item, planned_start_date, planned_end_date
|
data = frappe.db.sql("""select name, production_item, planned_start_date,
|
||||||
|
planned_end_date, status
|
||||||
from `tabProduction Order`
|
from `tabProduction Order`
|
||||||
where ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \
|
where ((ifnull(planned_start_date, '0000-00-00')!= '0000-00-00') \
|
||||||
and (planned_start_date between %(start)s and %(end)s) \
|
and (planned_start_date between %(start)s and %(end)s) \
|
||||||
|
|||||||
@@ -10,6 +10,15 @@ frappe.views.calendar["Production Order"] = {
|
|||||||
"allDay": "allDay"
|
"allDay": "allDay"
|
||||||
},
|
},
|
||||||
gantt: true,
|
gantt: true,
|
||||||
|
get_css_class: function(data) {
|
||||||
|
if(data.status==="Completed") {
|
||||||
|
return "success";
|
||||||
|
} else if(data.status==="In Process") {
|
||||||
|
return "warning";
|
||||||
|
} else {
|
||||||
|
return "danger";
|
||||||
|
}
|
||||||
|
},
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
|||||||
@@ -107,18 +107,14 @@ class Task(Document):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_events(start, end, filters=None):
|
def get_events(start, end, filters=None):
|
||||||
from frappe.desk.reportview import build_match_conditions
|
"""Returns events for Gantt / Calendar view rendering.
|
||||||
if not frappe.has_permission("Task"):
|
|
||||||
frappe.msgprint(_("No Permission"), raise_exception=1)
|
|
||||||
|
|
||||||
conditions = build_match_conditions("Task")
|
:param start: Start date-time.
|
||||||
conditions = conditions and (" and " + conditions) or ""
|
:param end: End date-time.
|
||||||
|
:param filters: Filters (JSON).
|
||||||
if filters:
|
"""
|
||||||
filters = json.loads(filters)
|
from frappe.desk.calendar import get_event_conditions
|
||||||
for key in filters:
|
conditions = get_event_conditions("Task", filters)
|
||||||
if filters[key]:
|
|
||||||
conditions += " and " + key + ' = "' + filters[key].replace('"', '\"') + '"'
|
|
||||||
|
|
||||||
data = frappe.db.sql("""select name, exp_start_date, exp_end_date,
|
data = frappe.db.sql("""select name, exp_start_date, exp_end_date,
|
||||||
subject, status, project from `tabTask`
|
subject, status, project from `tabTask`
|
||||||
|
|||||||
@@ -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, json
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import cstr, flt, get_datetime, get_time, getdate
|
from frappe.utils import cstr, flt, get_datetime, get_time, getdate
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
@@ -248,17 +248,8 @@ def get_events(start, end, filters=None):
|
|||||||
:param end: End date-time.
|
:param end: End date-time.
|
||||||
:param filters: Filters like workstation, project etc.
|
:param filters: Filters like workstation, project etc.
|
||||||
"""
|
"""
|
||||||
from frappe.desk.reportview import build_match_conditions
|
from frappe.desk.calendar import get_event_conditions
|
||||||
if not frappe.has_permission("Time Log"):
|
conditions = get_event_conditions("Time Log", filters)
|
||||||
frappe.msgprint(_("No Permission"), raise_exception=1)
|
|
||||||
|
|
||||||
conditions = build_match_conditions("Time Log")
|
|
||||||
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, from_time, to_time,
|
data = frappe.db.sql("""select name, from_time, to_time,
|
||||||
activity_type, task, project, production_order, workstation from `tabTime Log`
|
activity_type, task, project, production_order, workstation from `tabTime Log`
|
||||||
|
|||||||
@@ -471,3 +471,24 @@ def make_maintenance_visit(source_name, target_doc=None):
|
|||||||
}, target_doc)
|
}, target_doc)
|
||||||
|
|
||||||
return doclist
|
return doclist
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_events(start, end, filters=None):
|
||||||
|
"""Returns events for Gantt / Calendar view rendering.
|
||||||
|
|
||||||
|
:param start: Start date-time.
|
||||||
|
:param end: End date-time.
|
||||||
|
:param filters: Filters (JSON).
|
||||||
|
"""
|
||||||
|
from frappe.desk.calendar import get_event_conditions
|
||||||
|
conditions = get_event_conditions("Sales Order", filters)
|
||||||
|
|
||||||
|
data = frappe.db.sql("""select name, customer_name, delivery_status, billing_status, delivery_date
|
||||||
|
from `tabSales Order`
|
||||||
|
where (ifnull(delivery_date, '0000-00-00')!= '0000-00-00') \
|
||||||
|
and (delivery_date between %(start)s and %(end)s) {conditions}
|
||||||
|
""".format(conditions=conditions), {
|
||||||
|
"start": start,
|
||||||
|
"end": end
|
||||||
|
}, as_dict=True, update={"allDay": 0})
|
||||||
|
return data
|
||||||
|
|||||||
45
erpnext/selling/doctype/sales_order/sales_order_calendar.js
Normal file
45
erpnext/selling/doctype/sales_order/sales_order_calendar.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
frappe.views.calendar["Sales Order"] = {
|
||||||
|
field_map: {
|
||||||
|
"start": "delivery_date",
|
||||||
|
"end": "delivery_date",
|
||||||
|
"id": "name",
|
||||||
|
"title": "customer_name",
|
||||||
|
"allDay": "allDay"
|
||||||
|
},
|
||||||
|
gantt: true,
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"fieldname": "customer",
|
||||||
|
"options": "Customer",
|
||||||
|
"label": __("Customer")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"fieldname": "delivery_status",
|
||||||
|
"options": "Not Delivered\nFully Delivered\nPartly Delivered\nClosed\nNot Applicable",
|
||||||
|
"label": __("Delivery Status")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"fieldname": "billing_status",
|
||||||
|
"options": "Not Billed\nFully Billed\nPartly Billed\nClosed",
|
||||||
|
"label": __("Billing Status")
|
||||||
|
},
|
||||||
|
],
|
||||||
|
get_events_method: "erpnext.selling.doctype.sales_order.sales_order.get_events",
|
||||||
|
get_css_class: function(data) {
|
||||||
|
if(data.status=="Stopped") {
|
||||||
|
return "";
|
||||||
|
} if(data.delivery_status=="Not Delivered") {
|
||||||
|
return "danger";
|
||||||
|
} else if(data.delivery_status=="Partly Delivered") {
|
||||||
|
return "warning";
|
||||||
|
} else if(data.delivery_status=="Fully Delivered") {
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user