1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-06-21 01:48:21 +02:00

Test and cover treasury app

This commit is contained in:
Yohann D'ANELLO
2020-09-04 15:53:00 +02:00
parent b6847415b5
commit c03c18e93a
20 changed files with 438 additions and 31 deletions

View File

@ -16,21 +16,15 @@ class InvoiceForm(forms.ModelForm):
"""
def clean(self):
# If the invoice is locked, it can't be updated.
if self.instance and self.instance.locked:
for field_name in self.fields:
self.cleaned_data[field_name] = getattr(self.instance, field_name)
self.errors.clear()
self.add_error(None, _('This invoice is locked and can no longer be edited.'))
return self.cleaned_data
return super().clean()
def save(self, commit=True):
"""
If the invoice is locked, don't save it
"""
if not self.instance.locked:
super().save(commit)
return self.instance
class Meta:
model = Invoice
exclude = ('bde', 'date', 'tex', )