[UPDT] EMPLOYEE : Employee work info updation issue fixes in individual and bulk update and new database issues fixes

This commit is contained in:
Horilla
2024-05-16 14:26:44 +05:30
parent 9f468a4e64
commit a247b9ec3e
10 changed files with 338 additions and 298 deletions

View File

@@ -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()