mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-16 09:18:10 +00:00
Fixes for data migration
This commit is contained in:
@@ -91,7 +91,7 @@ def copy_part_parameters(apps, schema_editor):
|
|||||||
templates.append(ParameterTemplate(
|
templates.append(ParameterTemplate(
|
||||||
name=template.name,
|
name=template.name,
|
||||||
description=template.description,
|
description=template.description,
|
||||||
units=template.units,
|
units=template.units or '',
|
||||||
checkbox=template.checkbox,
|
checkbox=template.checkbox,
|
||||||
choices=template.choices,
|
choices=template.choices,
|
||||||
selectionlist=template.selectionlist,
|
selectionlist=template.selectionlist,
|
||||||
@@ -145,14 +145,14 @@ def copy_manufacturer_part_parameters(apps, schema_editor):
|
|||||||
|
|
||||||
for parameter in ManufacturerPartParameter.objects.all():
|
for parameter in ManufacturerPartParameter.objects.all():
|
||||||
# Find the corresponding ParameterTemplate
|
# Find the corresponding ParameterTemplate
|
||||||
template = ParameterTemplate.objects.filter(name=parameter.template.name).first()
|
template = ParameterTemplate.objects.filter(name=parameter.name).first()
|
||||||
|
|
||||||
if not template:
|
if not template:
|
||||||
# A matching template does not exist - let's create one
|
# A matching template does not exist - let's create one
|
||||||
template = ParameterTemplate.objects.create(
|
template = ParameterTemplate.objects.create(
|
||||||
name=parameter.name,
|
name=parameter.name,
|
||||||
description='',
|
description='',
|
||||||
units=parameter.units,
|
units=parameter.units or '',
|
||||||
model_type=None,
|
model_type=None,
|
||||||
checkbox=False
|
checkbox=False
|
||||||
)
|
)
|
||||||
@@ -162,8 +162,7 @@ def copy_manufacturer_part_parameters(apps, schema_editor):
|
|||||||
model_type=content_type,
|
model_type=content_type,
|
||||||
model_id=parameter.manufacturer_part.id,
|
model_id=parameter.manufacturer_part.id,
|
||||||
data=parameter.value,
|
data=parameter.value,
|
||||||
data_numeric=convert_to_numeric_value(parameter.value),
|
data_numeric=convert_to_numeric_value(parameter.value, parameter.units),
|
||||||
note=parameter.note
|
|
||||||
))
|
))
|
||||||
|
|
||||||
if len(parameters) > 0:
|
if len(parameters) > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user