fix: error in bulk attendance (#24806)

* fix: error in bulk attendance

* fix: no date selected scenario

* fix: translation and sider
This commit is contained in:
Jannat Patel 2021-03-09 20:41:58 +05:30 committed by GitHub
parent 78777d6ed4
commit d7ac2394e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 18 deletions

View File

@ -131,6 +131,10 @@ def mark_bulk_attendance(data):
data = json.loads(data) data = json.loads(data)
data = frappe._dict(data) data = frappe._dict(data)
company = frappe.get_value('Employee', data.employee, 'company') company = frappe.get_value('Employee', data.employee, 'company')
if not data.unmarked_days:
frappe.throw(_("Please select a date."))
return
for date in data.unmarked_days: for date in data.unmarked_days:
doc_dict = { doc_dict = {
'doctype': 'Attendance', 'doctype': 'Attendance',

View File

@ -27,6 +27,7 @@ frappe.listview_settings['Attendance'] = {
dialog.set_df_property("status", "hidden", 1); dialog.set_df_property("status", "hidden", 1);
dialog.set_df_property("month", "value", ''); dialog.set_df_property("month", "value", '');
dialog.set_df_property("unmarked_days", "options", []); dialog.set_df_property("unmarked_days", "options", []);
dialog.no_unmarked_days_left = false;
} }
}, },
{ {
@ -39,9 +40,14 @@ frappe.listview_settings['Attendance'] = {
if(dialog.fields_dict.employee.value && dialog.fields_dict.month.value) { if(dialog.fields_dict.employee.value && dialog.fields_dict.month.value) {
dialog.set_df_property("status", "hidden", 0); dialog.set_df_property("status", "hidden", 0);
dialog.set_df_property("unmarked_days", "options", []); dialog.set_df_property("unmarked_days", "options", []);
dialog.no_unmarked_days_left = false;
me.get_multi_select_options(dialog.fields_dict.employee.value, dialog.fields_dict.month.value).then(options =>{ me.get_multi_select_options(dialog.fields_dict.employee.value, dialog.fields_dict.month.value).then(options =>{
if (options.length > 0) {
dialog.set_df_property("unmarked_days", "hidden", 0); dialog.set_df_property("unmarked_days", "hidden", 0);
dialog.set_df_property("unmarked_days", "options", options); dialog.set_df_property("unmarked_days", "options", options);
} else {
dialog.no_unmarked_days_left = true;
}
}); });
} }
} }
@ -65,7 +71,10 @@ frappe.listview_settings['Attendance'] = {
}, },
], ],
primary_action(data) { primary_action(data) {
frappe.confirm(__('Mark attendance as <b>' + data.status + '</b> for <b>' + data.month +'</b>' + ' on selected dates?'), () => { if (cur_dialog.no_unmarked_days_left) {
frappe.msgprint(__("Attendance for the month of {0} , has already been marked for the Employee {1}",[dialog.fields_dict.month.value, dialog.fields_dict.employee.value]));
} else {
frappe.confirm(__('Mark attendance as {0} for {1} on selected dates?', [data.status,data.month]), () => {
frappe.call({ frappe.call({
method: "erpnext.hr.doctype.attendance.attendance.mark_bulk_attendance", method: "erpnext.hr.doctype.attendance.attendance.mark_bulk_attendance",
args: { args: {
@ -79,6 +88,7 @@ frappe.listview_settings['Attendance'] = {
} }
}); });
}); });
}
dialog.hide(); dialog.hide();
list_view.refresh(); list_view.refresh();
}, },