time log fixes
This commit is contained in:
parent
b744e16a83
commit
07a0d250ed
@ -10,13 +10,6 @@ frappe.ui.form.on("Time Log", "onload", function(frm) {
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Time Log", "refresh", function(frm) {
|
||||
var is_manufacturing = frm.doc.time_log_for=="Manufacturing" ? true : false;
|
||||
frm.toggle_reqd("production_order", is_manufacturing);
|
||||
frm.toggle_reqd("operation", is_manufacturing);
|
||||
frm.toggle_reqd("completed_qty", is_manufacturing);
|
||||
});
|
||||
|
||||
// set to time if hours is updated
|
||||
frappe.ui.form.on("Time Log", "hours", function(frm) {
|
||||
if(!frm.doc.from_time) {
|
||||
|
@ -237,5 +237,5 @@
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"title_field": "activity_type"
|
||||
"title_field": ""
|
||||
}
|
@ -25,6 +25,7 @@ class TimeLog(Document):
|
||||
self.validate_production_order()
|
||||
self.validate_project()
|
||||
self.validate_activity()
|
||||
self.validate_manufacturing()
|
||||
|
||||
def on_submit(self):
|
||||
self.update_production_order()
|
||||
@ -134,11 +135,26 @@ class TimeLog(Document):
|
||||
if self.time_log_for == 'Project':
|
||||
if not self.project:
|
||||
frappe.throw(_("Project is Mandatory."))
|
||||
|
||||
if self.time_log_for == "":
|
||||
self.project = None
|
||||
|
||||
def validate_activity(self):
|
||||
if self.time_log_for == 'Project':
|
||||
if not self.activity:
|
||||
if self.time_log_for != 'Manufacturing':
|
||||
if not self.activity_type:
|
||||
frappe.throw(_("Activity is Mandatory."))
|
||||
self.production_order = None
|
||||
self.operation = None
|
||||
self.quantity = None
|
||||
|
||||
def validate_manufacturing(self):
|
||||
if self.time_log_for == 'Manufacturing':
|
||||
if not self.production_order:
|
||||
frappe.throw(_("Production Order is Mandatory"))
|
||||
if not self.operation:
|
||||
frappe.throw(_("Operation is Mandatory"))
|
||||
if not self.completed_qty:
|
||||
self.completed_qty=0
|
||||
self.activity_type = None
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_workstation(production_order, operation):
|
||||
@ -176,7 +192,7 @@ def get_events(start, end, filters=None):
|
||||
|
||||
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 )
|
||||
where docstatus < 2 and ( 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user