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
This commit is contained in:
bcornwellmott 2017-07-28 02:02:45 -07:00 committed by Rushabh Mehta
parent bead70b43a
commit bab0c5a8a5
3 changed files with 73 additions and 4 deletions

View File

@ -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
}

View File

@ -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()
]);
});

View File

@ -170,6 +170,7 @@ class Timesheet(Document):
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 @@ class Timesheet(Document):
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 = ''