2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-03 13:58:47 +00:00

Fix edge case when converting stock item to variant

- If the stock item had been created as part of a Build Order, and subsequently "converted" to a variant part, the conversion operation will fail
- Patch allows the build reference to be linked based on either the base part, or any conversion options
This commit is contained in:
Oliver 2022-05-12 15:15:51 +10:00
parent 56f36d4b4b
commit 47ddafb728

View File

@ -556,7 +556,14 @@ class StockItem(MPTTModel):
# If the item points to a build, check that the Part references match # If the item points to a build, check that the Part references match
if self.build: if self.build:
if not self.part == self.build.part:
if self.part == self.build.part:
# Part references match exactly
pass
elif self.part in self.build.part.get_conversion_options():
# Part reference is one of the valid conversion options for the build output
pass
else:
raise ValidationError({ raise ValidationError({
'build': _("Build reference does not point to the same part object") 'build': _("Build reference does not point to the same part object")
}) })