diff --git a/asset/forms.py b/asset/forms.py index 069927392..f0fde614c 100644 --- a/asset/forms.py +++ b/asset/forms.py @@ -311,6 +311,10 @@ class AssetAllocationForm(ModelForm): }, ), } + + # def clean(self): + # cleaned_data = super.clean() + class AssetReturnForm(ModelForm): diff --git a/asset/static/src/asset/dashboard.js b/asset/static/src/asset/dashboard.js index 0492deb6e..c9c9e0b7f 100644 --- a/asset/static/src/asset/dashboard.js +++ b/asset/static/src/asset/dashboard.js @@ -58,7 +58,10 @@ $(document).ready(function() { console.log("Error", error); }, }); - + // $("#asset_request_view").on("click",function () { + // localStorage.setItem("activeTabAsset", "#tab_1"); + // window.location.replace("/asset/asset-request-allocation-view/?asset_request_status=Requested"); + // }) }); function emptyAssetAvialabeChart(assetAvailableChartChart,args,options){ diff --git a/asset/templates/asset/dashboard.html b/asset/templates/asset/dashboard.html index 15c8e5c67..831be710d 100644 --- a/asset/templates/asset/dashboard.html +++ b/asset/templates/asset/dashboard.html @@ -40,9 +40,11 @@
{% trans "Asset request" %} @@ -156,6 +158,29 @@ >
+ + + {% endblock content %} \ No newline at end of file diff --git a/asset/templates/request_allocation/asset_approve.html b/asset/templates/request_allocation/asset_approve.html index 7d8aeed07..30a4be47a 100644 --- a/asset/templates/request_allocation/asset_approve.html +++ b/asset/templates/request_allocation/asset_approve.html @@ -1,7 +1,9 @@ {% load i18n %}
{% trans "Asset Approve" %}
-
+ {% csrf_token %} + {{asset_allocation_form.non_field_errors}} + {{asset_allocation_form.errors}}
diff --git a/asset/views.py b/asset/views.py index 4c98296fd..4004c9fe9 100644 --- a/asset/views.py +++ b/asset/views.py @@ -567,13 +567,18 @@ def asset_request_approve(request, req_id): # Add additional fields to the dictionary post_data["assigned_to_employee_id"] = asset_request.requested_employee_id post_data["assigned_by_employee_id"] = request.user.employee_get - form = AssetAllocationForm(post_data) + form = AssetAllocationForm(post_data,request.FILES) + print("------------------------------------") + print(post_data) + print("------------------------------------") if form.is_valid(): asset = form.instance.asset_id.id asset = Asset.objects.filter(id=asset).first() asset.asset_status = "In use" asset.save() - form = form.save() + form = form.save(commit=False) + form.assigned_by_employee_id = request.user.employee_get + form.save() asset_request.asset_request_status = "Approved" asset_request.save() messages.success(request, _("Asset request approved successfully!."))