From 47ddafb72890ecfbf4480b8a2605687f6221c0e3 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 12 May 2022 15:15:51 +1000 Subject: [PATCH 1/2] 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 --- InvenTree/stock/models.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/InvenTree/stock/models.py b/InvenTree/stock/models.py index 53e1321e1a..a46d43b007 100644 --- a/InvenTree/stock/models.py +++ b/InvenTree/stock/models.py @@ -556,7 +556,14 @@ class StockItem(MPTTModel): # If the item points to a build, check that the Part references match 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({ 'build': _("Build reference does not point to the same part object") }) From 59cf9825fe9d11adbc124a758dc4e505a1828e94 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 12 May 2022 15:16:26 +1000 Subject: [PATCH 2/2] Update comment --- InvenTree/part/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 492da8f5de..96ffa581f4 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2233,7 +2233,7 @@ class Part(MPTTModel): for child in children: parts.append(child) - # Immediate parent + # Immediate parent, and siblings if self.variant_of: parts.append(self.variant_of)