respect defaults

This commit is contained in:
Matthias 2021-10-23 23:48:42 +02:00
parent 8e6aaa89f9
commit 612832c3e7
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -47,6 +47,7 @@ from stock.models import StockLocation
import common.settings as inventree_settings import common.settings as inventree_settings
from . import forms as part_forms from . import forms as part_forms
from . import settings as part_settings
from .bom import MakeBomTemplate, ExportBom, IsValidBOMFormat from .bom import MakeBomTemplate, ExportBom, IsValidBOMFormat
from order.models import PurchaseOrderLineItem from order.models import PurchaseOrderLineItem
@ -389,16 +390,16 @@ class PartImport(FileManagementFormView):
default_location=optional_matches['default_location'], default_location=optional_matches['default_location'],
default_supplier=optional_matches['default_supplier'], default_supplier=optional_matches['default_supplier'],
variant_of=optional_matches['variant_of'], variant_of=optional_matches['variant_of'],
active=str2bool(part_data.get('active', None)), active=str2bool(part_data.get('active', True)),
base_cost=part_data.get('base_cost', None), base_cost=part_data.get('base_cost', None),
multiple=part_data.get('multiple', None), multiple=part_data.get('multiple', None),
assembly=str2bool(part_data.get('assembly', None)), assembly=str2bool(part_data.get('assembly', part_settings.part_assembly_default())),
component=str2bool(part_data.get('component', None)), component=str2bool(part_data.get('component', part_settings.part_component_default())),
is_template=str2bool(part_data.get('is_template', None)), is_template=str2bool(part_data.get('is_template', part_settings.part_template_default())),
purchaseable=str2bool(part_data.get('purchaseable', None)), purchaseable=str2bool(part_data.get('purchaseable', part_settings.part_purchaseable_default())),
salable=str2bool(part_data.get('salable', None)), salable=str2bool(part_data.get('salable', part_settings.part_salable_default())),
trackable=str2bool(part_data.get('trackable', None)), trackable=str2bool(part_data.get('trackable', part_settings.part_trackable_default())),
virtual=str2bool(part_data.get('virtual', None)), virtual=str2bool(part_data.get('virtual', part_settings.part_virtual_default())),
) )
try: try:
new_part.save() new_part.save()