Commit cccc8acf authored by Élie Bouttier's avatar Élie Bouttier

fix regression

parent 92a5c04e
......@@ -338,7 +338,8 @@ class ServicePortInline(PortInline):
class ServiceForm(ModelForm):
def clean_adhesion(self):
if self.instance.adhesion.pk != self.cleaned_data['adhesion'].pk \
if hasattr(self.instance, 'adhesion') \
and self.instance.adhesion.pk != self.cleaned_data['adhesion'].pk \
and not self.instance.is_active():
raise ValidationError('Il n’est pas possible de ré-affecter à un autre adhérent un service inactif (i.e. sans allocations actives).')
return self.cleaned_data['adhesion']
......@@ -361,7 +362,7 @@ class ServiceAdmin(admin.ModelAdmin):
form = ServiceForm
def save_model(self, request, srv, form, change):
if 'adhesion' in form.changed_data:
if srv.pk and 'adhesion' in form.changed_data:
with transaction.atomic():
old_srv = Service.objects.get(pk=srv.pk)
adhesion = srv.adhesion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment