[FIX] ASSET : Owner field change and will filled up if it assigned to an employee

This commit is contained in:
Horilla
2024-08-31 16:48:57 +05:30
parent b9bb95dd56
commit dae6ba8a5f
3 changed files with 12 additions and 7 deletions

View File

@@ -55,7 +55,7 @@ class AssetForm(ModelForm):
model = Asset
fields = "__all__"
exclude = ["is_active"]
exclude = ["is_active,owner"]
widgets = {
"asset_name": forms.TextInput(
attrs={"placeholder": "Macbook Pro.", "class": "oh-input w-100"}
@@ -159,6 +159,7 @@ class DocumentForm(forms.ModelForm):
"type": "File",
"class": "form-control",
"multiple": "True",
"accept": ".jpeg, .jpg, .png, .pdf",
}
)
)

View File

@@ -96,13 +96,16 @@
{{asset_form.asset_name.errors}}
</div>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-input__label" for="{{asset_form.owner.id_for_label}}" >{% trans "Owner" %}</label>
{{asset_form.owner }}
{{asset_form.owner.errors }}
{% if instance.asset_status == "In use" and instance.assetassignment_set.last %}
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-input__label" for="{{asset_form.owner.id_for_label}}">{% trans "Current User" %}</label>
{% with assigned=instance.assetassignment_set.last %}
<input type="text" class="oh-input w-100" value="{{ assigned.assigned_to_employee_id }}" readonly>
{% endwith %}
</div>
</div>
</div>
{% endif %}
</div>
<div class="oh-input__group ">
<label class="oh-input__label" for="{{asset_form.asset_description.id_for_label}}" >{% trans "Asset Description" %}</label>

View File

@@ -196,6 +196,7 @@ def asset_update(request, asset_id):
asset_form.save()
messages.success(request, _("Asset Updated"))
context = {
"instance": instance,
"asset_form": asset_form,
"asset_under": asset_under,
"pg": previous_data,