From a247b9ec3e768bde706eaec1f1472cc31cf241d4 Mon Sep 17 00:00:00 2001 From: Horilla Date: Thu, 16 May 2024 14:26:44 +0530 Subject: [PATCH] [UPDT] EMPLOYEE : Employee work info updation issue fixes in individual and bulk update and new database issues fixes --- employee/forms.py | 72 +++- .../templates/employee/profile/bank_info.html | 2 +- .../employee/profile/personal_info.html | 12 +- .../employee/update_form/bank_details.html | 144 +++---- .../employee/update_form/personal_info.html | 10 +- .../employee/update_form/work_details.html | 388 +++++++++--------- .../employee_personal_info/bulk_update.html | 1 + .../tabs/allowance_deduction-tab.html | 2 +- employee/templates/tabs/history.html | 2 +- employee/views.py | 3 +- 10 files changed, 338 insertions(+), 298 deletions(-) diff --git a/employee/forms.py b/employee/forms.py index cc31faca1..470192ae7 100644 --- a/employee/forms.py +++ b/employee/forms.py @@ -301,27 +301,57 @@ class EmployeeWorkInformationForm(ModelForm): if isinstance(field, forms.ModelChoiceField) and field.label in field_names: if field.label is not None: field_name = field_names.get(field.label) - if field.queryset.model != Employee and field_name: - translated_label = _(field.label) - empty_label = _("---Choose {label}---").format( - label=translated_label - ) - self.fields[label] = forms.ChoiceField( - choices=[("", empty_label)] - + list(field.queryset.values_list("id", f"{field_name}")), - required=field.required, - label=translated_label, - initial=field.initial, - widget=forms.Select( - attrs={ - "class": "oh-select oh-select-2 select2-hidden-accessible", - "onchange": f'onDynamicCreate(this.value,"{urls.get(field.label)}");', - } - ), - ) - self.fields[label].choices += [ - ("create", _("Create New {} ").format(translated_label)) - ] + # print(field.label) + if field.label == "Department": + if field.queryset.model != Employee and field_name: + translated_label = _(field.label) + empty_label = _("---Choose {label}---").format( + label=translated_label + ) + self.fields[label] = forms.ChoiceField( + choices=[("", empty_label)] + + list( + field.queryset.values_list("id", f"{field_name}") + ), + required=field.required, + label=translated_label, + initial=field.initial, + widget=forms.Select( + attrs={ + "class": "oh-select oh-select-2 select2-hidden-accessible", + "onchange": f'onDynamicCreateDep(this.value,"{urls.get(field.label)}");', + } + ), + ) + self.fields[label].choices += [ + ("create", _("Create New {} ").format(translated_label)) + ] + + else: + + if field.queryset.model != Employee and field_name: + translated_label = _(field.label) + empty_label = _("---Choose {label}---").format( + label=translated_label + ) + self.fields[label] = forms.ChoiceField( + choices=[("", empty_label)] + + list( + field.queryset.values_list("id", f"{field_name}") + ), + required=field.required, + label=translated_label, + initial=field.initial, + widget=forms.Select( + attrs={ + "class": "oh-select oh-select-2 select2-hidden-accessible", + "onchange": f'onDynamicCreate(this.value,"{urls.get(field.label)}");', + } + ), + ) + self.fields[label].choices += [ + ("create", _("Create New {} ").format(translated_label)) + ] def clean(self): cleaned_data = super().clean() diff --git a/employee/templates/employee/profile/bank_info.html b/employee/templates/employee/profile/bank_info.html index 05ae7e645..2aed1736d 100644 --- a/employee/templates/employee/profile/bank_info.html +++ b/employee/templates/employee/profile/bank_info.html @@ -80,7 +80,7 @@
diff --git a/employee/templates/employee/profile/personal_info.html b/employee/templates/employee/profile/personal_info.html index 4b002f0bb..52831fe01 100644 --- a/employee/templates/employee/profile/personal_info.html +++ b/employee/templates/employee/profile/personal_info.html @@ -177,14 +177,12 @@ -
-
-
- +
+
+
-
diff --git a/employee/templates/employee/update_form/bank_details.html b/employee/templates/employee/update_form/bank_details.html index 187a0bdc2..708c2270d 100644 --- a/employee/templates/employee/update_form/bank_details.html +++ b/employee/templates/employee/update_form/bank_details.html @@ -1,84 +1,86 @@ {% load i18n %} -
-
-
-
-
- {% csrf_token %} -
-
-
- - {{bank_form.bank_name}} -
-
-
-
- - {{bank_form.account_number}} - {{bank_form.account_number.errors}} -
-
-
-
-
-
- - {{bank_form.branch}} -
-
-
-
- - {{bank_form.any_other_code1}} -
-
-
-
-
-
- - {{bank_form.address}} -
-
-
-
-
- - -
-
+
+
+
+ +
+
+ {% csrf_token %} +
+
- - + + {{bank_form.bank_name}} +
+
+
+
+ + {{bank_form.account_number}} + {{bank_form.account_number.errors}} +
-
-
-
+
+
- - {{bank_form.city}} + + {{bank_form.branch}} +
+
+
+
+ + {{bank_form.any_other_code1}} +
-
+
+
- - {{bank_form.any_other_code2}} + + {{bank_form.address}} +
+
+
+ + +
+
+
+ + +
+
+
+
+
+
+ + {{bank_form.city}} +
+
+
+
+ + {{bank_form.any_other_code2}} +
+
+
+
+
+ +
+
-
-
- -
- +
-
diff --git a/employee/templates/employee/update_form/personal_info.html b/employee/templates/employee/update_form/personal_info.html index a1f20710a..f4d85e229 100644 --- a/employee/templates/employee/update_form/personal_info.html +++ b/employee/templates/employee/update_form/personal_info.html @@ -195,13 +195,11 @@
-
-
-
- -
diff --git a/employee/templates/employee/update_form/work_details.html b/employee/templates/employee/update_form/work_details.html index 680e54c6e..96234f3ee 100644 --- a/employee/templates/employee/update_form/work_details.html +++ b/employee/templates/employee/update_form/work_details.html @@ -1,224 +1,233 @@ {% load i18n %} - -
+
- - - - - - -
-
-
- {{history_form.as_history_modal}} {% csrf_token %} -
-
-
- - {{work_form.department_id}} -
-
-
-
- - {{work_form.job_position_id}} -
-
-
-
-
+ class="oh-modal" + id="dynamicCreateModal" + role="dialog" + aria-hidden="true" + > +
+
+ + + + + + +
+
+ + {{history_form.as_history_modal}} {% csrf_token %} +
+
- - {{work_form.job_role_id}} + + {{work_form.department_id}} +
+
+
+
+ + {{work_form.job_position_id}} +
-
-
- - {{work_form.shift_id}} +
+
+
+ + {{work_form.job_role_id}} +
+
+
+
+ + {{work_form.shift_id}} +
-
-
-
-
- - {{work_form.work_type_id}} +
+
+
+ + {{work_form.work_type_id}} +
+
+
+
+ + {{work_form.employee_type_id}} +
-
-
- - {{work_form.employee_type_id}} +
+
+
+ + {{work_form.reporting_manager_id}} +
+
+
+
+ + {{work_form.company_id}} +
-
-
-
-
- - {{work_form.reporting_manager_id}} +
+
+
+ + {{work_form.location}} +
+
+
+
+ + {{work_form.email}} +
-
-
- - {{work_form.company_id}} +
+
+
+ + {{work_form.date_joining}} +
+
+
+
+ + {{work_form.contract_end_date}} +
-
-
-
-
- - {{work_form.location}} +
+
+
+ + {{work_form.basic_salary}} +
+
+
+
+ + {{work_form.salary_hour}} +
-
-
- - {{work_form.email}} -
-
-
-
-
-
- - {{work_form.date_joining}} -
-
-
-
- - {{work_form.contract_end_date}} -
-
-
-
-
-
- - {{work_form.basic_salary}} -
-
-
-
- - {{work_form.salary_hour}} -
-
-
-
-
-
- - {{work_form.tags}} +
+
+
+ + {{work_form.tags}} +
-
-
-
- -
- +
+
+ +
+ +