Update stock item variant conversion form to use new function

This commit is contained in:
Oliver 2022-04-19 13:04:17 +10:00
parent 87de7e4beb
commit 48170ee096
2 changed files with 14 additions and 1 deletions

View File

@ -739,7 +739,10 @@ class StockItem(MPTTModel):
self.add_tracking_entry(
StockHistoryCode.CONVERTED_TO_VARIANT,
user,
notes=notes
deltas={
'part': variant.pk,
},
notes=_('Converted to part') + ': ' + variant.full_name,
)
def get_item_owner(self):

View File

@ -643,6 +643,16 @@ class StockItemConvert(AjaxUpdateView):
form.fields['part'].queryset = item.part.get_conversion_options()
return form
def save(self, obj, form):
stock_item = self.get_object()
variant = form.cleaned_data.get('part', None)
stock_item.convert_to_variant(variant, user=self.request.user)
return stock_item
class StockLocationCreate(AjaxCreateView):