[IMP] Remove inter module dependency (#274)

This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made:

1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase.
2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation.
3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules.

These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code.

**NOTE**
For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations.

- `python3 manage.py makemigrations`
- `python3 manage.py migrate base`
- `python3 manage.py migrate`





* [IMP] ASSET: Asset module dependency removal from other Horilla apps

* [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps

* [IMP] BASE: Base module dependency removal from other Horilla apps

* [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps

* [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps

* [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps

* [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps

* [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps

* [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps

* [IMP] LEAVE: Leave module dependency removal from other Horilla apps

* [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps

* [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps

* [IMP] PMS: PMS module dependency removal from other Horilla apps

* [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps

* [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps

* [IMP] HORILLA: Dependency removal updates

* [IMP] TEMPLATES: Dependency removal updates

* [IMP] STATIC: Dependency removal updates

* [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps

* [ADD] HORILLA: methods.py

* [UPDT] HORILLA: Settings.py

* [FIX] EMPLOYEE: About tab issue

* Update horilla_settings.py

* Remove dummy db init password
This commit is contained in:
Horilla
2024-08-05 14:22:44 +05:30
committed by GitHub
parent 746272d801
commit 2fee7c18bb
308 changed files with 12414 additions and 9577 deletions

View File

@@ -9,6 +9,7 @@ import uuid
from typing import Any
from django import forms
from django.apps import apps
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
@@ -18,10 +19,12 @@ from base.methods import reload_queryset
from employee.filters import EmployeeFilter
from employee.models import BonusPoint, Employee
from horilla import horilla_middlewares
from horilla.methods import get_horilla_model_class
from horilla_widgets.forms import HorillaForm
from horilla_widgets.widgets.horilla_multi_select_field import HorillaMultiSelectField
from horilla_widgets.widgets.select_widgets import HorillaMultiSelectWidget
from leave.models import AvailableLeave, LeaveType
# from leave.models import AvailableLeave, LeaveType
from notifications.signals import notify
from payroll.models import tax_models as models
from payroll.models.models import (
@@ -384,7 +387,6 @@ class GeneratePayslipForm(HorillaForm):
filter_class=EmployeeFilter,
filter_instance_contex_name="f",
filter_template_path="employee_filters.html",
required=True,
),
label="Employee",
)
@@ -395,6 +397,7 @@ class GeneratePayslipForm(HorillaForm):
cleaned_data = super().clean()
start_date = cleaned_data.get("start_date")
end_date = cleaned_data.get("end_date")
today = datetime.date.today()
if end_date < start_date:
raise forms.ValidationError(
@@ -685,13 +688,16 @@ class ReimbursementForm(ModelForm):
fields = "__all__"
exclude = ["is_active"]
def get_encashable_leaves(self, employee):
leaves = LeaveType.objects.filter(
employee_available_leave__employee_id=employee,
employee_available_leave__total_leave_days__gte=1,
is_encashable=True,
)
return leaves
if apps.is_installed("leave"):
def get_encashable_leaves(self, employee):
LeaveType = get_horilla_model_class(app_label="leave", model="leavetype")
leaves = LeaveType.objects.filter(
employee_available_leave__employee_id=employee,
employee_available_leave__total_leave_days__gte=1,
is_encashable=True,
)
return leaves
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -707,13 +713,18 @@ class ReimbursementForm(ModelForm):
else self.instance.employee_id
)
self.initial["employee_id"] = employee.id
assigned_leaves = self.get_encashable_leaves(employee)
self.assigned_leaves = AvailableLeave.objects.filter(
leave_type_id__in=assigned_leaves, employee_id=employee
)
self.fields["leave_type_id"].queryset = assigned_leaves
self.fields["leave_type_id"].empty_label = None
self.fields["employee_id"].empty_label = None
if apps.is_installed("leave"):
AvailableLeave = get_horilla_model_class(
app_label="leave", model="availableleave"
)
assigned_leaves = self.get_encashable_leaves(employee)
self.assigned_leaves = AvailableLeave.objects.filter(
leave_type_id__in=assigned_leaves, employee_id=employee
)
self.fields["leave_type_id"].queryset = assigned_leaves
self.fields["leave_type_id"].empty_label = None
self.fields["employee_id"].empty_label = None
type_attr = self.fields["type"].widget.attrs
type_attr["onchange"] = "toggleReimbursmentType($(this))"

View File

@@ -22,7 +22,6 @@ from payroll.models.models import (
PayrollGeneralSetting,
ReimbursementFile,
ReimbursementrequestComment,
WorkRecord,
)
@@ -155,20 +154,6 @@ class ContractForm(ModelForm):
return f"/payroll/update-contract-status/{instance.pk}"
class WorkRecordForm(ModelForm):
"""
WorkRecordForm
"""
class Meta:
"""
Meta class for additional options
"""
fields = "__all__"
model = WorkRecord
class ReimbursementRequestCommentForm(ModelForm):
"""
ReimbursementRequestCommentForm form