Activity Cost - Mandatory removed for Employee.
diff --git a/erpnext/projects/doctype/activity_cost/activity_cost.json b/erpnext/projects/doctype/activity_cost/activity_cost.json
index bdc147e..fafea58 100644
--- a/erpnext/projects/doctype/activity_cost/activity_cost.json
+++ b/erpnext/projects/doctype/activity_cost/activity_cost.json
@@ -11,41 +11,6 @@
"fields": [
{
"allow_on_submit": 0,
- "fieldname": "employee",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Employee",
- "no_copy": 0,
- "options": "Employee",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0
- },
- {
- "fieldname": "employee_name",
- "fieldtype": "Data",
- "label": "Employee Name",
- "options": "",
- "permlevel": 0,
- "precision": "",
- "read_only": 1
- },
- {
- "fieldname": "column_break_2",
- "fieldtype": "Column Break",
- "permlevel": 0,
- "precision": ""
- },
- {
- "allow_on_submit": 0,
"fieldname": "activity_type",
"fieldtype": "Link",
"hidden": 0,
@@ -65,6 +30,41 @@
"set_only_once": 0
},
{
+ "fieldname": "column_break_2",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
+ "allow_on_submit": 0,
+ "fieldname": "employee",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Employee",
+ "no_copy": 0,
+ "options": "Employee",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0
+ },
+ {
+ "fieldname": "employee_name",
+ "fieldtype": "Data",
+ "label": "Employee Name",
+ "options": "",
+ "permlevel": 0,
+ "precision": "",
+ "read_only": 1
+ },
+ {
"fieldname": "section_break_4",
"fieldtype": "Section Break",
"permlevel": 0,
@@ -136,7 +136,7 @@
"is_submittable": 0,
"issingle": 0,
"istable": 0,
- "modified": "2015-06-11 06:50:47.999788",
+ "modified": "2015-06-16 03:12:25.644839",
"modified_by": "Administrator",
"module": "Projects",
"name": "Activity Cost",
diff --git a/erpnext/projects/doctype/activity_cost/activity_cost.py b/erpnext/projects/doctype/activity_cost/activity_cost.py
index 8cd04f5..f2c5099 100644
--- a/erpnext/projects/doctype/activity_cost/activity_cost.py
+++ b/erpnext/projects/doctype/activity_cost/activity_cost.py
@@ -15,12 +15,21 @@
self.check_unique()
def set_title(self):
- if not self.employee_name:
- self.employee_name = frappe.db.get_value("Employee", self.employee, "employee_name")
- self.title = _("{0} for {1}").format(self.employee_name, self.activity_type)
-
+ if self.employee:
+ if not self.employee_name:
+ self.employee_name = frappe.db.get_value("Employee", self.employee, "employee_name")
+ self.title = _("{0} for {1}").format(self.employee_name, self.activity_type)
+ else:
+ self.title = self.activity_type
+
def check_unique(self):
- if frappe.db.sql("""select name from `tabActivity Cost` where employee_name= %s and activity_type= %s and name != %s""",
- (self.employee_name, self.activity_type, self.name)):
- frappe.throw(_("Activity Cost exists for Employee {0} against Activity Type - {1}")
- .format(self.employee, self.activity_type), DuplicationError)
+ if self.employee:
+ if frappe.db.sql("""select name from `tabActivity Cost` where employee_name= %s and activity_type= %s and name != %s""",
+ (self.employee_name, self.activity_type, self.name)):
+ frappe.throw(_("Activity Cost exists for Employee {0} against Activity Type - {1}")
+ .format(self.employee, self.activity_type), DuplicationError)
+ else:
+ if frappe.db.sql("""select name from `tabActivity Cost` where employee_name IS NULL and activity_type= %s and name != %s""",
+ (self.activity_type, self.name)):
+ frappe.throw(_("Default Activity Cost exists for Activity Type - {0}")
+ .format(self.activity_type), DuplicationError)
diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py
index aa5647e..e863561 100644
--- a/erpnext/projects/doctype/time_log/time_log.py
+++ b/erpnext/projects/doctype/time_log/time_log.py
@@ -272,4 +272,7 @@
def get_activity_cost(employee=None, activity_type=None):
rate = frappe.db.sql("""select costing_rate, billing_rate from `tabActivity Cost` where employee= %s
and activity_type= %s""", (employee, activity_type), as_dict=1)
+ if not rate:
+ rate = frappe.db.sql("""select costing_rate, billing_rate from `tabActivity Cost` where employee IS NULL
+ and activity_type= %s""", (activity_type), as_dict=1)
return rate[0] if rate else {}