2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 22:06:28 +00:00

generalising for done()

This commit is contained in:
2021-05-18 10:47:56 +02:00
parent ad4902ea44
commit 64f8846e99
3 changed files with 29 additions and 42 deletions

View File

@ -822,28 +822,7 @@ class PartImport(FileManagementFormView):
def done(self, form_list, **kwargs):
""" Create items """
items = {}
for form_key, form_value in self.get_all_cleaned_data().items():
# Split key from row value
try:
(field, idx) = form_key.split('-')
except ValueError:
continue
try:
if idx not in items:
# Insert into items
items.update({
idx: {
self.form_field_map[field]: form_value,
}
})
else:
# Update items
items[idx][self.form_field_map[field]] = form_value
except KeyError:
pass
items = self.get_clean_items()
import_done = 0
import_error = []