Skip to content

Commit

Permalink
Fix for PurchaseOrderLineItem.receive (#258)
Browse files Browse the repository at this point in the history
* Fix for PurchaseOrderLineItem.receive

- Fix default value for "expiry_date"

* Refactor PurchaseOrderLineItem.receive
  • Loading branch information
SchrodingersGat authored Jan 13, 2025
1 parent d508bc6 commit 81ac887
Showing 1 changed file with 20 additions and 11 deletions.
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

0 comments on commit 81ac887

Please sign in to comment.