Add disable check for Activity Type (#10120)
* Add disable check for Activity Type
* Add check for disabled in Timesheet
* Codacy fixes
* Fixed bugs
* Restore permissions
diff --git a/erpnext/projects/doctype/activity_type/activity_type.json b/erpnext/projects/doctype/activity_type/activity_type.json
index 65a0fa1..dc50a09 100644
--- a/erpnext/projects/doctype/activity_type/activity_type.json
+++ b/erpnext/projects/doctype/activity_type/activity_type.json
@@ -1,5 +1,6 @@
{
"allow_copy": 0,
+ "allow_guest_to_view": 0,
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:activity_type",
@@ -12,6 +13,7 @@
"editable_grid": 0,
"fields": [
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -22,7 +24,8 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
- "in_list_view": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
"in_standard_filter": 0,
"label": "Activity Type",
"length": 0,
@@ -39,6 +42,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -49,6 +53,7 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Costing Rate",
@@ -67,6 +72,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -77,6 +83,7 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"length": 0,
@@ -94,6 +101,7 @@
"unique": 0
},
{
+ "allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
@@ -104,6 +112,7 @@
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
+ "in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Default Billing Rate",
@@ -120,20 +129,51 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "0",
+ "fieldname": "disabled",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Disabled",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
}
],
+ "has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"icon": "icon-flag",
"idx": 1,
"image_view": 0,
"in_create": 0,
- "in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-12-13 12:38:18.218618",
+ "modified": "2017-07-25 20:11:05.229092",
"modified_by": "Administrator",
"module": "Projects",
"name": "Activity Type",
@@ -149,11 +189,11 @@
"export": 1,
"if_owner": 0,
"import": 1,
- "is_custom": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
+ "restrict": 0,
"role": "System Manager",
"set_user_permissions": 0,
"share": 1,
@@ -175,6 +215,7 @@
"print": 1,
"read": 1,
"report": 1,
+ "restrict": 0,
"role": "Projects User",
"set_user_permissions": 0,
"share": 1,
@@ -196,6 +237,7 @@
"print": 0,
"read": 1,
"report": 0,
+ "restrict": 0,
"role": "Employee",
"set_user_permissions": 0,
"share": 0,
@@ -206,6 +248,8 @@
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
+ "show_name_in_global_search": 0,
"sort_order": "ASC",
+ "track_changes": 0,
"track_seen": 0
}
\ No newline at end of file
diff --git a/erpnext/projects/doctype/activity_type/test_activity_type.js b/erpnext/projects/doctype/activity_type/test_activity_type.js
new file mode 100644
index 0000000..8023121
--- /dev/null
+++ b/erpnext/projects/doctype/activity_type/test_activity_type.js
@@ -0,0 +1,20 @@
+QUnit.test("test: Activity Type", function (assert) {
+ // number of asserts
+ assert.expect(1);
+ let done = assert.async();
+
+ frappe.run_serially([
+ // insert a new Activity Type
+ () => frappe.set_route("List", "Activity Type", "List"),
+ () => frappe.new_doc("Activity Type"),
+ () => frappe.timeout(1),
+ () => frappe.click_link('Edit in full page'),
+ () => cur_frm.set_value("activity_type", "Test Activity"),
+ () => frappe.click_button('Save'),
+ () => frappe.timeout(1),
+ () => {
+ assert.equal(cur_frm.doc.name,"Test Activity");
+ },
+ () => done()
+ ]);
+});
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index 95fd420..db00cdf 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -170,6 +170,7 @@
for data in self.get('time_logs'):
self.check_workstation_timings(data)
self.validate_overlap(data)
+ validate_activity(data)
def validate_overlap(self, data):
if self.production_order:
@@ -270,6 +271,10 @@
data.billing_amount = data.billing_rate * hours
data.costing_amount = data.costing_rate * hours
+def validate_activity(data):
+ if frappe.get_value('Activity Type', data.activity_type, 'disabled'):
+ frappe.throw(_("Activity type for row {0} is disabled").format(data.idx))
+
@frappe.whitelist()
def get_projectwise_timesheet_data(project, parent=None):
cond = ''