added verbose name to storages to be printed on labels etc.

This commit is contained in:
2024-11-16 13:22:59 +01:00
parent 50ecaa2cc0
commit a77f46d697
7 changed files with 29 additions and 3 deletions

View File

@@ -484,6 +484,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
context['add_storage_form'] = add_storage_form
change_storage_form = ChangeStorageForm()
change_storage_form.fields['storage_name'].initial = self.object.name
change_storage_form.fields['verbose_name'].initial = self.object.verbose_name
change_storage_form.fields['responsible'].initial = self.object.responsible.id
change_storage_form.fields['is_template'].initial = self.object.is_template
context['change_storage_form'] = change_storage_form
@@ -498,6 +499,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
sub_name = f.cleaned_data['storage_name']
try:
Storage.objects.create(name=sub_name,
verbose_name=f.cleaned_data.get('verbose_name'),
parent_storage=self.object,
responsible=f.cleaned_data['responsible'],
is_template=f.cleaned_data['is_template'],
@@ -514,6 +516,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
sub_name = f.cleaned_data['storage_name']
try:
self.object.name = f.cleaned_data['storage_name']
self.object.verbose_name = f.cleaned_data.get('verbose_name')
self.object.responsible = f.cleaned_data['responsible']
self.object.is_template = f.cleaned_data['is_template']
self.object.save()