API: Fix crash when creating addons with order change endpoint (#3363)

This commit is contained in:
Julian Rother
2023-06-02 20:00:40 +02:00
committed by GitHub
parent d91d942eac
commit 9813e59210
2 changed files with 31 additions and 0 deletions

View File

@@ -70,6 +70,8 @@ class OrderPositionCreateForExistingOrderSerializer(OrderPositionCreateSerialize
def validate(self, data):
data = super().validate(data)
if 'order' in self.context:
data['order'] = self.context['order']
if data.get('addon_to'):
try:
data['addon_to'] = data['order'].positions.get(positionid=data['addon_to'])