+ {% if withdraw.account.deleted or not withdraw.account.recorded %}
+ {% fa5_icon 'exclamation-triangle' %}
+ {% endif %}
{{ withdraw.intervention.identifier }}
|
diff --git a/intervention/forms.py b/intervention/forms.py
index 0641880a..5e69a755 100644
--- a/intervention/forms.py
+++ b/intervention/forms.py
@@ -439,7 +439,7 @@ class NewWithdrawForm(BaseModalForm):
label=_("Eco-account"),
label_suffix="",
help_text=_("Only recorded accounts can be selected for withdraws"),
- queryset=EcoAccount.objects.filter(deleted=None, recorded__isnull=False),
+ queryset=EcoAccount.objects.filter(deleted=None),
widget=autocomplete.ModelSelect2(
url="accounts-autocomplete",
attrs={
@@ -506,6 +506,14 @@ class NewWithdrawForm(BaseModalForm):
else:
acc = self.instance
+ if not acc.recorded:
+ self.add_error(
+ "account",
+ _("Eco-account {} is not recorded yet. You can only withdraw from recorded accounts.").format(acc.identifier)
+ )
+ return False
+
+ # Calculate valid surface
sum_surface = acc.get_surface()
sum_surface_withdraws = acc.get_surface_withdraws()
rest_surface = sum_surface - sum_surface_withdraws
diff --git a/intervention/templates/intervention/detail/includes/withdraws.html b/intervention/templates/intervention/detail/includes/withdraws.html
index ba577060..be22e205 100644
--- a/intervention/templates/intervention/detail/includes/withdraws.html
+++ b/intervention/templates/intervention/detail/includes/withdraws.html
@@ -40,10 +40,10 @@