Holiday List name changed and workstation filter added to time log

This commit is contained in:
Neil Trini Lasrado 2014-11-25 18:55:42 +05:30 committed by Nabin Hait
parent 812cd8a8ce
commit 5ec7542519
9 changed files with 41 additions and 23 deletions

View File

@ -1,5 +1,6 @@
{
"allow_import": 1,
"autoname": "field:holiday_list_name",
"creation": "2013-01-10 16:34:14",
"docstatus": 0,
"doctype": "DocType",
@ -13,7 +14,8 @@
"oldfieldname": "holiday_list_name",
"oldfieldtype": "Data",
"permlevel": 0,
"reqd": 1
"reqd": 1,
"unique": 1
},
{
"fieldname": "is_default",
@ -72,7 +74,7 @@
],
"icon": "icon-calendar",
"idx": 1,
"modified": "2014-05-09 02:16:38.887266",
"modified": "2014-11-25 15:42:22.419054",
"modified_by": "Administrator",
"module": "HR",
"name": "Holiday List",

View File

@ -11,9 +11,6 @@ from frappe import throw, _
from frappe.model.document import Document
class HolidayList(Document):
def autoname(self):
self.name = make_autoname(self.fiscal_year + "/" + self.holiday_list_name + "/.###")
def validate(self):
self.update_default_holiday_list()

View File

@ -58,9 +58,9 @@ $.extend(cur_frm.cscript, {
bom_no: function() {
return this.frm.call({
doc: this.frm.doc,
method: "get_production_order_operations",
method: "set_production_order_operations",
callback: function(r) {
if(!r.exc) refresh_field("get_production_order_operations");
if(!r.exc) refresh_field("production_order_operations");
}
});
},

View File

@ -145,7 +145,7 @@ class ProductionOrder(Document):
from erpnext.stock.utils import update_bin
update_bin(args)
def get_production_order_operations(self):
def set_production_order_operations(self):
self.set('production_order_operations', [])
operations = frappe.db.sql("""select operation, opn_description, workstation, hour_rate, time_in_mins,
operating_cost, fixed_cycle_cost from `tabBOM Operation` where parent = %s""", self.bom_no, as_dict=1)
@ -230,5 +230,6 @@ def make_time_log(name, operation, from_time=None, to_time=None, qty=None, proje
time_log.operation= operation
time_log.qty= qty
time_log.workstation= workstation
time_log.calculate_total_hours()
if from_time and to_time :
time_log.calculate_total_hours()
return time_log

View File

@ -67,7 +67,7 @@ class TestProductionOrder(unittest.TestCase):
})
prod_order.get_production_order_operations()
prod_order.set_production_order_operations()
prod_order.production_order_operations[0].update({
"planned_start_time": "2014-11-25 00:00:00",
"planned_end_time": "2014-11-25 10:00:00"

View File

@ -262,6 +262,7 @@
"precision": ""
},
{
"allow_on_submit": 1,
"fieldname": "make_time_log",
"fieldtype": "Button",
"label": "Make Time Log",
@ -276,7 +277,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"modified": "2014-11-13 16:47:31.015973",
"modified": "2014-11-25 13:34:10.697445",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "Production Order Operation",

View File

@ -7,9 +7,9 @@ import unittest
test_dependencies = ["Warehouse"]
test_records = frappe.get_test_records('Workstation')
class TestWorkstation(unittest.TestCase):
def test_validate_timings(self):
wks = frappe.get_doc("Workstation", "_Test Workstation 1")
self.assertEqual(1,wks.check_workstation_for_operation_time("2013-02-01 05:00:00", "2013-02-02 20:00:00"))
self.assertEqual(None,wks.check_workstation_for_operation_time("2013-02-03 10:00:00", "2013-02-03 20:00:00"))

View File

@ -4,7 +4,7 @@
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
import frappe, json
from frappe import _
from frappe.utils import cstr, cint, comma_and
@ -135,23 +135,31 @@ def get_workstation(production_order, operation):
parent=%s and operation = %s""", (idx, production_order, operation), as_dict=1)[0]
@frappe.whitelist()
def get_events(start, end):
def get_events(start, end, filters=None):
from frappe.desk.reportview import build_match_conditions
if not frappe.has_permission("Time Log"):
frappe.msgprint(_("No Permission"), raise_exception=1)
match = build_match_conditions("Time Log")
data = frappe.db.sql("""select name, from_time, to_time,
activity_type, task, project from `tabTime Log`
where from_time between '%(start)s' and '%(end)s' or to_time between '%(start)s' and '%(end)s'
%(match)s""" % {
"start": start,
"end": end,
"match": match and (" and " + match) or ""
}, as_dict=True, update={"allDay": 0})
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,
activity_type, task, project, production_order, workstation from `tabTime Log`
where ( from_time between %(start)s and %(end)s or to_time between %(start)s and %(end)s )
{conditions}""".format(conditions=conditions), {
"start": start,
"end": end
}, as_dict=True, update={"allDay": 0})
for d in data:
d.title = d.name + ": " + (d.activity_type or "[Activity Type not set]")
d.title = d.name + ": " + (d.activity_type or d.production_order or "")
if d.task:
d.title += " for Task: " + d.task
if d.project:

View File

@ -9,5 +9,14 @@ frappe.views.calendar["Time Log"] = {
"title": "title",
"allDay": "allDay"
},
gantt: true,
filters: [
{
"fieldtype": "Link",
"fieldname": "workstation",
"options": "Workstation",
"label": __("Workstation")
},
],
get_events_method: "erpnext.projects.doctype.time_log.time_log.get_events"
}