Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for PurchaseOrderLineItem.receive #258

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions inventree/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def getOrder(self):
"""
return PurchaseOrder(self._api, self.order)

def receive(self, quantity=None, status=10, location=None, expiry_date='', batch_code='', serial_numbers=''):
def receive(self, quantity=None, status=10, location=None, expiry_date=None, batch_code=None, serial_numbers=None):
"""
Mark this line item as received.

Expand Down Expand Up @@ -202,19 +202,28 @@ def receive(self, quantity=None, status=10, location=None, expiry_date='', batch
except: # noqa:E722
location_id = int(location)

item_data = {
'line_item': self.pk,
'supplier_part': self.part,
'quantity': quantity,
'status': status,
'location': location_id
}

# Optional fields which may be set
if expiry_date:
item_data['expiry_date'] = expiry_date

if batch_code:
item_data['batch_code'] = batch_code

if serial_numbers:
item_data['serial_numbers'] = serial_numbers

# Prepare request data
data = {
'items': [
{
'line_item': self.pk,
'supplier_part': self.part,
'quantity': quantity,
'status': status,
'location': location_id,
'expiry_date': expiry_date,
'batch_code': batch_code,
'serial_numbers': serial_numbers
}
item_data,
],
'location': location_id
}
Expand Down
Loading