diff --git a/assets/forms.py b/assets/forms.py
index c727a9d1..a7d4d052 100644
--- a/assets/forms.py
+++ b/assets/forms.py
@@ -1,4 +1,5 @@
from django import forms
+from django.core.exceptions import ValidationError
from assets import models
@@ -7,7 +8,15 @@ class AssetForm(forms.ModelForm):
class Meta:
model = models.Asset
fields = '__all__'
+
+ def __init__(self, *args, **kwargs):
+ super(AssetForm, self).__init__(*args, **kwargs)
+ self.fields['asset_id'].disabled = True #You should not be able to change the asset ID, either in update or create
+ def clean_date_sold(self):
+ if self.cleaned_data["date_sold"] and self.cleaned_data["date_acquired"] > self.cleaned_data["date_sold"]:
+ raise ValidationError("Cannot sell an item before it is acquired")
+ return self.cleaned_data["date_sold"]
class SupplierForm(forms.ModelForm):
class Meta:
diff --git a/assets/templates/asset_update.html b/assets/templates/asset_update.html
index 6c3de1e0..3b906aad 100644
--- a/assets/templates/asset_update.html
+++ b/assets/templates/asset_update.html
@@ -19,7 +19,11 @@
{% endif %}
-
+{% if create %}
+
-
-
- {% include 'partials/asset_buttons.html' %}
-
-
+
{% include 'partials/confirm_delete.html' with object=object %}
-{% endblock %}
-
-{% block js %}
-
-
-{# #}
-
-
-
-
-{% endblock %}
+{% endblock %}
\ No newline at end of file
diff --git a/assets/templates/partials/asset_buttons.html b/assets/templates/partials/asset_buttons.html
index d752e254..25eeac9c 100644
--- a/assets/templates/partials/asset_buttons.html
+++ b/assets/templates/partials/asset_buttons.html
@@ -1,16 +1,16 @@