From 93638bd179eb05b7c493168ed033002074a101ae Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Fri, 30 Jan 2015 19:55:26 +0530 Subject: [PATCH 1/4] Time Log - Project made compulsory for time logs with time_log_for selected as 'Project' Activity Type Madetory criteria removed Compleated Quantity hidden if time_log_for is not set as Manufacturing --- erpnext/projects/doctype/time_log/time_log.json | 3 ++- erpnext/projects/doctype/time_log/time_log.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json index e60e75ee1c..f55ce1b8cd 100644 --- a/erpnext/projects/doctype/time_log/time_log.json +++ b/erpnext/projects/doctype/time_log/time_log.json @@ -76,7 +76,7 @@ "options": "Activity Type", "permlevel": 0, "read_only": 0, - "reqd": 1 + "reqd": 0 }, { "depends_on": "eval:doc.time_log_for != 'Manufacturing'", @@ -116,6 +116,7 @@ "read_only": 1 }, { + "depends_on": "eval:doc.time_log_for == 'Manufacturing'", "description": "Operation completed for how many finished goods?", "fieldname": "completed_qty", "fieldtype": "Float", diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index f4cb89e74e..7bb083501e 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -23,6 +23,7 @@ class TimeLog(Document): self.validate_time_log_for() self.check_workstation_timings() self.validate_production_order() + self.validate_project() def on_submit(self): self.update_production_order() @@ -127,6 +128,11 @@ class TimeLog(Document): from `tabTime Log` where production_order = %s and operation = %s and docstatus=1""", (self.production_order, self.operation), as_dict=1)[0] + + def validate_project(self): + if self.time_log_for == 'Project': + if not self.project: + frappe.throw(_("Project is Mandatory.")) @frappe.whitelist() def get_workstation(production_order, operation): From b744e16a8307dd43da6c4b8477d862ea42b59c75 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Fri, 30 Jan 2015 20:00:16 +0530 Subject: [PATCH 2/4] Activity made compulsory for time_log_type Project --- erpnext/projects/doctype/time_log/time_log.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index 7bb083501e..a829d4449f 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -24,6 +24,7 @@ class TimeLog(Document): self.check_workstation_timings() self.validate_production_order() self.validate_project() + self.validate_activity() def on_submit(self): self.update_production_order() @@ -134,6 +135,11 @@ class TimeLog(Document): if not self.project: frappe.throw(_("Project is Mandatory.")) + def validate_activity(self): + if self.time_log_for == 'Project': + if not self.activity: + frappe.throw(_("Activity is Mandatory.")) + @frappe.whitelist() def get_workstation(production_order, operation): """Returns workstation name from Production Order against an associated Operation. From 07a0d250ed31183fe98004fa1afde57acfbea584 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 3 Feb 2015 10:51:00 +0530 Subject: [PATCH 3/4] time log fixes --- erpnext/projects/doctype/time_log/time_log.js | 7 ------ .../projects/doctype/time_log/time_log.json | 2 +- erpnext/projects/doctype/time_log/time_log.py | 24 +++++++++++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/erpnext/projects/doctype/time_log/time_log.js b/erpnext/projects/doctype/time_log/time_log.js index 9a53836db3..cfcd35cfe6 100644 --- a/erpnext/projects/doctype/time_log/time_log.js +++ b/erpnext/projects/doctype/time_log/time_log.js @@ -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) { diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json index f55ce1b8cd..16102d744e 100644 --- a/erpnext/projects/doctype/time_log/time_log.json +++ b/erpnext/projects/doctype/time_log/time_log.json @@ -237,5 +237,5 @@ "write": 1 } ], - "title_field": "activity_type" + "title_field": "" } \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index a829d4449f..b1d4b8aead 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -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 From 11cd4f6c30b432a4d9dceea740ab2b5ba1e3523f Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 4 Feb 2015 12:31:11 +0530 Subject: [PATCH 4/4] time log activity type made mandatory, new activity type manufacturing created --- .../doctype/production_order/production_order.py | 1 + erpnext/projects/doctype/time_log/time_log.js | 6 ++++++ erpnext/projects/doctype/time_log/time_log.json | 7 +++---- erpnext/projects/doctype/time_log/time_log.py | 16 +++++----------- .../setup/page/setup_wizard/install_fixtures.py | 3 ++- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 396ec98c51..a96224882c 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -291,6 +291,7 @@ def make_time_log(name, operation, from_time, to_time, qty=None, project=None, time_log.project = project time_log.operation= operation time_log.workstation= workstation + time_log.activity_type= "Manufacturing" time_log.completed_qty = flt(qty) if from_time and to_time : time_log.calculate_total_hours() diff --git a/erpnext/projects/doctype/time_log/time_log.js b/erpnext/projects/doctype/time_log/time_log.js index cfcd35cfe6..3e28e7074f 100644 --- a/erpnext/projects/doctype/time_log/time_log.js +++ b/erpnext/projects/doctype/time_log/time_log.js @@ -68,5 +68,11 @@ $.extend(cur_frm.cscript, { } } }); + }, + + time_log_for: function(doc) { + if (doc.time_log_for == 'Manufacturing') { + cur_frm.set_value("activity_type", "Manufacturing") + } } }); diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json index 16102d744e..9dc2d5932b 100644 --- a/erpnext/projects/doctype/time_log/time_log.json +++ b/erpnext/projects/doctype/time_log/time_log.json @@ -68,7 +68,7 @@ "reqd": 0 }, { - "depends_on": "eval:doc.time_log_for != 'Manufacturing'", + "depends_on": "", "fieldname": "activity_type", "fieldtype": "Link", "in_list_view": 0, @@ -76,7 +76,7 @@ "options": "Activity Type", "permlevel": 0, "read_only": 0, - "reqd": 0 + "reqd": 1 }, { "depends_on": "eval:doc.time_log_for != 'Manufacturing'", @@ -116,7 +116,6 @@ "read_only": 1 }, { - "depends_on": "eval:doc.time_log_for == 'Manufacturing'", "description": "Operation completed for how many finished goods?", "fieldname": "completed_qty", "fieldtype": "Float", @@ -237,5 +236,5 @@ "write": 1 } ], - "title_field": "" + "title_field": "activity_type" } \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index b1d4b8aead..a7401b4abf 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -24,7 +24,6 @@ class TimeLog(Document): self.check_workstation_timings() self.validate_production_order() self.validate_project() - self.validate_activity() self.validate_manufacturing() def on_submit(self): @@ -136,15 +135,7 @@ class TimeLog(Document): 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 != 'Manufacturing': - if not self.activity_type: - frappe.throw(_("Activity is Mandatory.")) - self.production_order = None - self.operation = None - self.quantity = None + self.project = None def validate_manufacturing(self): if self.time_log_for == 'Manufacturing': @@ -154,7 +145,10 @@ class TimeLog(Document): frappe.throw(_("Operation is Mandatory")) if not self.completed_qty: self.completed_qty=0 - self.activity_type = None + else: + self.production_order = None + self.operation = None + self.quantity = None @frappe.whitelist() def get_workstation(production_order, operation): diff --git a/erpnext/setup/page/setup_wizard/install_fixtures.py b/erpnext/setup/page/setup_wizard/install_fixtures.py index 531219281d..f83ab35053 100644 --- a/erpnext/setup/page/setup_wizard/install_fixtures.py +++ b/erpnext/setup/page/setup_wizard/install_fixtures.py @@ -135,7 +135,8 @@ def install(country=None): {'doctype': 'Activity Type', 'activity_type': _('Proposal Writing')}, {'doctype': 'Activity Type', 'activity_type': _('Execution')}, {'doctype': 'Activity Type', 'activity_type': _('Communication')}, - + {'doctype': 'Activity Type', 'activity_type': _('Manufacturing')}, + # Industry Type {'doctype': 'Industry Type', 'industry': _('Accounting')}, {'doctype': 'Industry Type', 'industry': _('Advertising')},