code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def get_object(self, request, *args, **kwargs):
"""This is where settings from the URL etc will be obtained."""
# Help:
# https://django.readthedocs.io/en/stable/ref/contrib/syndication.html
obj = {}
obj['ordertype'] = kwargs['ordertype']
obj['include_completed'] = bool(... | This is where settings from the URL etc will be obtained. | get_object | python | inventree/InvenTree | src/backend/InvenTree/order/api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py | MIT |
def items(self, obj):
"""Return a list of Orders.
Filters:
- Only return those which have a target_date set
- Only return incomplete orders, unless include_completed is set to True
"""
if obj['ordertype'] == 'purchase-order':
if obj['include_completed'] is Fa... | Return a list of Orders.
Filters:
- Only return those which have a target_date set
- Only return incomplete orders, unless include_completed is set to True
| items | python | inventree/InvenTree | src/backend/InvenTree/order/api.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/api.py | MIT |
def currency(self):
"""Return the currency associated with this order instance.
Rules:
- If the order_currency field is set, return that
- Otherwise, return the currency associated with the company
- Finally, return the default currency code
"""
if self.order_cur... | Return the currency associated with this order instance.
Rules:
- If the order_currency field is set, return that
- Otherwise, return the currency associated with the company
- Finally, return the default currency code
| currency | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def update_total_price(self, commit=True):
"""Recalculate and save the total_price for this order."""
self.total_price = self.calculate_total_price(target_currency=self.currency)
if commit:
self.save() | Recalculate and save the total_price for this order. | update_total_price | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def calculate_total_price(self, target_currency=None):
"""Calculates the total price of all order lines, and converts to the specified target currency.
If not specified, the default system currency is used.
If currency conversion fails (e.g. there are no valid conversion rates),
then w... | Calculates the total price of all order lines, and converts to the specified target currency.
If not specified, the default system currency is used.
If currency conversion fails (e.g. there are no valid conversion rates),
then we simply return zero, rather than attempting some other calculatio... | calculate_total_price | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def save(self, *args, **kwargs):
"""Custom save method for the order models.
Enforces various business logics:
- Ensures the object is not locked
- Ensures that the reference field is rebuilt whenever the instance is saved.
"""
# check if we are updating the model, not a... | Custom save method for the order models.
Enforces various business logics:
- Ensures the object is not locked
- Ensures that the reference field is rebuilt whenever the instance is saved.
| save | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def check_locked(self, db: bool = False) -> bool:
"""Check if this order is 'locked'.
Args:
db: If True, check with the database. If False, check the instance (default False).
"""
return (
self.LOCK_SETTING
and get_global_setting(self.LOCK_SETTING)
... | Check if this order is 'locked'.
Args:
db: If True, check with the database. If False, check the instance (default False).
| check_locked | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def check_complete(self, db: bool = False) -> bool:
"""Check if this order is 'complete'.
Args:
db: If True, check with the database. If False, check the instance (default False).
"""
status = self.get_db_instance().status if db else self.status
return status in self... | Check if this order is 'complete'.
Args:
db: If True, check with the database. If False, check the instance (default False).
| check_complete | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean(self):
"""Custom clean method for the generic order class."""
super().clean()
# Check if a responsible owner is required for this order type
if self.REQUIRE_RESPONSIBLE_SETTING:
if get_global_setting(self.REQUIRE_RESPONSIBLE_SETTING, backup_value=False):
... | Custom clean method for the generic order class. | clean | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean_line_item(self, line):
"""Clean a line item for this order.
Used when duplicating an existing line item,
to ensure it is 'fresh'.
"""
line.pk = None
line.target_date = None
line.order = self | Clean a line item for this order.
Used when duplicating an existing line item,
to ensure it is 'fresh'.
| clean_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def report_context(self) -> BaseOrderReportContext:
"""Generate context data for the reporting interface."""
return {
'description': self.description,
'extra_lines': self.extra_lines,
'lines': self.lines,
'order': self,
'reference': self.refere... | Generate context data for the reporting interface. | report_context | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def overdue_filter(cls):
"""A generic implementation of an 'overdue' filter for the Model class.
It requires any subclasses to implement the get_status_class() class method
"""
today = InvenTree.helpers.current_date()
return (
Q(status__in=cls.get_status_class().OPEN... | A generic implementation of an 'overdue' filter for the Model class.
It requires any subclasses to implement the get_status_class() class method
| overdue_filter | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def is_overdue(self):
"""Method to determine if this order is overdue.
Makes use of the overdue_filter() method to avoid code duplication
"""
return (
self.__class__.objects.filter(pk=self.pk)
.filter(self.__class__.overdue_filter())
.exists()
... | Method to determine if this order is overdue.
Makes use of the overdue_filter() method to avoid code duplication
| is_overdue | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean_line_item(self, line):
"""Clean a line item for this PurchaseOrder."""
super().clean_line_item(line)
line.received = 0 | Clean a line item for this PurchaseOrder. | clean_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def subscribed_users(self) -> list[User]:
"""Return a list of users subscribed to this PurchaseOrder.
By this, we mean users to are interested in any of the parts associated with this order.
"""
subscribed_users = set()
for line in self.lines.all():
if line.part and... | Return a list of users subscribed to this PurchaseOrder.
By this, we mean users to are interested in any of the parts associated with this order.
| subscribed_users | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def add_line_item(
self,
supplier_part,
quantity,
group: bool = True,
reference: str = '',
purchase_price=None,
destination=None,
):
"""Add a new line item to this purchase order.
This function will check that:
* The supplier part matc... | Add a new line item to this purchase order.
This function will check that:
* The supplier part matches the supplier specified for this purchase order
* The quantity is greater than zero
Arguments:
supplier_part: The supplier_part to add
quantity : The number of ... | add_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_place(self, *args, **kwargs):
"""Marks the PurchaseOrder as PLACED.
Order must be currently PENDING.
"""
if self.can_issue:
self.status = PurchaseOrderStatus.PLACED.value
self.issue_date = InvenTree.helpers.current_date()
self.save()
... | Marks the PurchaseOrder as PLACED.
Order must be currently PENDING.
| _action_place | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_complete(self, *args, **kwargs):
"""Marks the PurchaseOrder as COMPLETE.
Order must be currently PLACED.
"""
if self.status == PurchaseOrderStatus.PLACED:
self.status = PurchaseOrderStatus.COMPLETE.value
self.complete_date = InvenTree.helpers.current_... | Marks the PurchaseOrder as COMPLETE.
Order must be currently PLACED.
| _action_complete | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def can_issue(self):
"""Return True if this order can be issued."""
return self.status in [
PurchaseOrderStatus.PENDING.value,
PurchaseOrderStatus.ON_HOLD.value,
] | Return True if this order can be issued. | can_issue | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def place_order(self):
"""Attempt to transition to PLACED status."""
return self.handle_transition(
self.status, PurchaseOrderStatus.PLACED.value, self, self._action_place
) | Attempt to transition to PLACED status. | place_order | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def complete_order(self):
"""Attempt to transition to COMPLETE status."""
return self.handle_transition(
self.status, PurchaseOrderStatus.COMPLETE.value, self, self._action_complete
) | Attempt to transition to COMPLETE status. | complete_order | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def cancel_order(self):
"""Attempt to transition to CANCELLED status."""
return self.handle_transition(
self.status, PurchaseOrderStatus.CANCELLED.value, self, self._action_cancel
) | Attempt to transition to CANCELLED status. | cancel_order | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def can_hold(self):
"""Return True if this order can be placed on hold."""
return self.status in [
PurchaseOrderStatus.PENDING.value,
PurchaseOrderStatus.PLACED.value,
] | Return True if this order can be placed on hold. | can_hold | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_hold(self, *args, **kwargs):
"""Mark this purchase order as 'on hold'."""
if self.can_hold:
self.status = PurchaseOrderStatus.ON_HOLD.value
self.save()
trigger_event(PurchaseOrderEvents.HOLD, id=self.pk) | Mark this purchase order as 'on hold'. | _action_hold | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def receive_line_item(
self, line, location, quantity, user, status=StockStatus.OK.value, **kwargs
):
"""Receive a line item (or partial line item) against this PurchaseOrder.
Arguments:
line: The PurchaseOrderLineItem to receive against
location: The StockLocation t... | Receive a line item (or partial line item) against this PurchaseOrder.
Arguments:
line: The PurchaseOrderLineItem to receive against
location: The StockLocation to receive the item into
quantity: The quantity to receive
user: The User performing the action
... | receive_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean_line_item(self, line):
"""Clean a line item for this SalesOrder."""
super().clean_line_item(line)
line.shipped = 0 | Clean a line item for this SalesOrder. | clean_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def subscribed_users(self) -> list[User]:
"""Return a list of users subscribed to this SalesOrder.
By this, we mean users to are interested in any of the parts associated with this order.
"""
subscribed_users = set()
for line in self.lines.all():
if line.part:
... | Return a list of users subscribed to this SalesOrder.
By this, we mean users to are interested in any of the parts associated with this order.
| subscribed_users | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def stock_allocations(self):
"""Return a queryset containing all allocations for this order."""
return SalesOrderAllocation.objects.filter(
line__in=[line.pk for line in self.lines.all()]
) | Return a queryset containing all allocations for this order. | stock_allocations | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def can_complete(self, raise_error=False, allow_incomplete_lines=False):
"""Test if this SalesOrder can be completed.
Throws a ValidationError if cannot be completed.
"""
try:
if self.status == SalesOrderStatus.COMPLETE.value:
raise ValidationError(_('Order i... | Test if this SalesOrder can be completed.
Throws a ValidationError if cannot be completed.
| can_complete | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_place(self, *args, **kwargs):
"""Change this order from 'PENDING' to 'IN_PROGRESS'."""
if self.can_issue:
self.status = SalesOrderStatus.IN_PROGRESS.value
self.issue_date = InvenTree.helpers.current_date()
self.save()
trigger_event(SalesOrderE... | Change this order from 'PENDING' to 'IN_PROGRESS'. | _action_place | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_hold(self, *args, **kwargs):
"""Mark this sales order as 'on hold'."""
if self.can_hold:
self.status = SalesOrderStatus.ON_HOLD.value
self.save()
trigger_event(SalesOrderEvents.HOLD, id=self.pk) | Mark this sales order as 'on hold'. | _action_hold | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_cancel(self, *args, **kwargs):
"""Cancel this order (only if it is "open").
Executes:
- Mark the order as 'cancelled'
- Delete any StockItems which have been allocated
"""
if not self.can_cancel:
return False
self.status = SalesOrderStatu... | Cancel this order (only if it is "open").
Executes:
- Mark the order as 'cancelled'
- Delete any StockItems which have been allocated
| _action_cancel | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def ship_order(self, user, **kwargs):
"""Attempt to transition to SHIPPED status."""
return self.handle_transition(
self.status,
SalesOrderStatus.SHIPPED.value,
self,
self._action_complete,
user=user,
**kwargs,
) | Attempt to transition to SHIPPED status. | ship_order | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def complete_order(self, user, **kwargs):
"""Attempt to transition to COMPLETED status."""
return self.handle_transition(
self.status,
SalesOrderStatus.COMPLETED.value,
self,
self._action_complete,
user=user,
**kwargs,
) | Attempt to transition to COMPLETED status. | complete_order | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def pending_allocations(self):
"""Return a queryset of any pending allocations for this order.
Allocations are pending if:
a) They are not associated with a SalesOrderShipment
b) The linked SalesOrderShipment has not been shipped
"""
Q1 = Q(shipment=None)
Q2 = Q... | Return a queryset of any pending allocations for this order.
Allocations are pending if:
a) They are not associated with a SalesOrderShipment
b) The linked SalesOrderShipment has not been shipped
| pending_allocations | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def after_save_sales_order(sender, instance: SalesOrder, created: bool, **kwargs):
"""Callback function to be executed after a SalesOrder is saved.
- If the SALESORDER_DEFAULT_SHIPMENT setting is enabled, create a default shipment
- Ignore if the database is not ready for access
- Ignore if data import... | Callback function to be executed after a SalesOrder is saved.
- If the SALESORDER_DEFAULT_SHIPMENT setting is enabled, create a default shipment
- Ignore if the database is not ready for access
- Ignore if data import is active
| after_save_sales_order | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def save(self, *args, **kwargs):
"""Custom save method for the OrderLineItem model.
Calls save method on the linked order
"""
if self.order and self.order.check_locked():
raise ValidationError({
'reference': _('The order is locked and cannot be modified')
... | Custom save method for the OrderLineItem model.
Calls save method on the linked order
| save | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def delete(self, *args, **kwargs):
"""Custom delete method for the OrderLineItem model.
Calls save method on the linked order
"""
if self.order and self.order.check_locked():
raise ValidationError({
'reference': _('The order is locked and cannot be modified')... | Custom delete method for the OrderLineItem model.
Calls save method on the linked order
| delete | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def total_line_price(self):
"""Return the total price for this line item."""
if self.price:
return self.quantity * self.price | Return the total price for this line item. | total_line_price | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean(self):
"""Custom clean method for the PurchaseOrderLineItem model.
Ensure the supplier part matches the supplier
"""
super().clean()
if self.order.supplier and self.part:
# Supplier part *must* point to the same supplier!
if self.part.supplier ... | Custom clean method for the PurchaseOrderLineItem model.
Ensure the supplier part matches the supplier
| clean | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def __str__(self):
"""Render a string representation of a PurchaseOrderLineItem instance."""
return '{n} x {part} - {po}'.format(
n=decimal2string(self.quantity),
part=self.part.SKU if self.part else 'unknown part',
po=self.order,
) | Render a string representation of a PurchaseOrderLineItem instance. | __str__ | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def get_base_part(self):
"""Return the base part.Part object for the line item.
Note: Returns None if the SupplierPart is not set!
"""
if self.part is None:
return None
return self.part.part | Return the base part.Part object for the line item.
Note: Returns None if the SupplierPart is not set!
| get_base_part | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def get_destination(self):
"""Show where the line item is or should be placed.
NOTE: If a line item gets split when received, only an arbitrary
stock items location will be reported as the location for the
entire line.
"""
for item in stock.models.StockItem.o... | Show where the line item is or should be placed.
NOTE: If a line item gets split when received, only an arbitrary
stock items location will be reported as the location for the
entire line.
| get_destination | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def remaining(self):
"""Calculate the number of items remaining to be received."""
r = self.quantity - self.received
return max(r, 0) | Calculate the number of items remaining to be received. | remaining | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def update_pricing(self):
"""Update pricing information based on the supplier part data."""
if self.part:
price = self.part.get_price(
self.quantity, currency=self.purchase_price_currency
)
if price is None or self.quantity == 0:
retur... | Update pricing information based on the supplier part data. | update_pricing | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean(self):
"""Perform extra validation steps for this SalesOrderLineItem instance."""
super().clean()
if self.part:
if self.part.virtual:
raise ValidationError({
'part': _('Virtual part cannot be assigned to a sales order')
}... | Perform extra validation steps for this SalesOrderLineItem instance. | clean | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def fulfilled_quantity(self):
"""Return the total stock quantity fulfilled against this line item."""
if not self.pk:
return 0
query = self.order.stock_items.filter(part=self.part).aggregate(
fulfilled=Coalesce(Sum('quantity'), Decimal(0))
)
return query... | Return the total stock quantity fulfilled against this line item. | fulfilled_quantity | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def allocated_quantity(self):
"""Return the total stock quantity allocated to this LineItem.
This is a summation of the quantity of each attached StockItem
"""
if not self.pk:
return 0
query = self.allocations.aggregate(
allocated=Coalesce(Sum('quantity'... | Return the total stock quantity allocated to this LineItem.
This is a summation of the quantity of each attached StockItem
| allocated_quantity | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def is_fully_allocated(self):
"""Return True if this line item is fully allocated."""
if self.order.status == SalesOrderStatus.SHIPPED:
return self.fulfilled_quantity() >= self.quantity
return self.allocated_quantity() >= self.quantity | Return True if this line item is fully allocated. | is_fully_allocated | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def check_can_complete(self, raise_error=True):
"""Check if this shipment is able to be completed."""
try:
if self.shipment_date:
# Shipment has already been sent!
raise ValidationError(_('Shipment has already been sent'))
if self.allocations.coun... | Check if this shipment is able to be completed. | check_can_complete | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def complete_shipment(self, user, **kwargs):
"""Complete this particular shipment.
Executes:
1. Update any stock items associated with this shipment
2. Update the "shipped" quantity of all associated line items
3. Set the "shipment_date" to now
"""
import order.t... | Complete this particular shipment.
Executes:
1. Update any stock items associated with this shipment
2. Update the "shipped" quantity of all associated line items
3. Set the "shipment_date" to now
| complete_shipment | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean(self):
"""Validate the SalesOrderAllocation object.
Executes:
- Cannot allocate stock to a line item without a part reference
- The referenced part must match the part associated with the line item
- Allocated quantity cannot exceed the quantity of the stock item
... | Validate the SalesOrderAllocation object.
Executes:
- Cannot allocate stock to a line item without a part reference
- The referenced part must match the part associated with the line item
- Allocated quantity cannot exceed the quantity of the stock item
- Allocation quantity mus... | clean | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def complete_allocation(self, user):
"""Complete this allocation (called when the parent SalesOrder is marked as "shipped").
Executes:
- Determine if the referenced StockItem needs to be "split" (if allocated quantity != stock quantity)
- Mark the StockItem as belonging to the Customer ... | Complete this allocation (called when the parent SalesOrder is marked as "shipped").
Executes:
- Determine if the referenced StockItem needs to be "split" (if allocated quantity != stock quantity)
- Mark the StockItem as belonging to the Customer (this will remove it from stock)
| complete_allocation | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean_line_item(self, line):
"""Clean a line item for this ReturnOrder."""
super().clean_line_item(line)
line.received_date = None
line.outcome = ReturnOrderLineStatus.PENDING.value | Clean a line item for this ReturnOrder. | clean_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def subscribed_users(self) -> list[User]:
"""Return a list of users subscribed to this ReturnOrder.
By this, we mean users to are interested in any of the parts associated with this order.
"""
subscribed_users = set()
for line in self.lines.all():
if line.item and l... | Return a list of users subscribed to this ReturnOrder.
By this, we mean users to are interested in any of the parts associated with this order.
| subscribed_users | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_hold(self, *args, **kwargs):
"""Mark this order as 'on hold' (if allowed)."""
if self.can_hold:
self.status = ReturnOrderStatus.ON_HOLD.value
self.save()
trigger_event(ReturnOrderEvents.HOLD, id=self.pk) | Mark this order as 'on hold' (if allowed). | _action_hold | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_cancel(self, *args, **kwargs):
"""Cancel this ReturnOrder (if not already cancelled)."""
if self.can_cancel:
self.status = ReturnOrderStatus.CANCELLED.value
self.save()
trigger_event(ReturnOrderEvents.CANCELLED, id=self.pk)
# Notify users tha... | Cancel this ReturnOrder (if not already cancelled). | _action_cancel | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_complete(self, *args, **kwargs):
"""Complete this ReturnOrder (if not already completed)."""
if self.status == ReturnOrderStatus.IN_PROGRESS.value:
self.status = ReturnOrderStatus.COMPLETE.value
self.complete_date = InvenTree.helpers.current_date()
self.sa... | Complete this ReturnOrder (if not already completed). | _action_complete | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def _action_place(self, *args, **kwargs):
"""Issue this ReturnOrder (if currently pending)."""
if self.can_issue:
self.status = ReturnOrderStatus.IN_PROGRESS.value
self.issue_date = InvenTree.helpers.current_date()
self.save()
trigger_event(ReturnOrderEve... | Issue this ReturnOrder (if currently pending). | _action_place | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def receive_line_item(self, line, location, user, **kwargs):
"""Receive a line item against this ReturnOrder.
Arguments:
line: ReturnOrderLineItem to receive
location: StockLocation to receive the item to
user: User performing the action
Keyword Arguments:
... | Receive a line item against this ReturnOrder.
Arguments:
line: ReturnOrderLineItem to receive
location: StockLocation to receive the item to
user: User performing the action
Keyword Arguments:
note: Additional notes to add to the tracking entry
... | receive_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def clean(self):
"""Perform extra validation steps for the ReturnOrderLineItem model."""
super().clean()
if not self.item:
raise ValidationError({'item': _('Stock item must be specified')})
if self.quantity > self.item.quantity:
raise ValidationError({
... | Perform extra validation steps for the ReturnOrderLineItem model. | clean | python | inventree/InvenTree | src/backend/InvenTree/order/models.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/models.py | MIT |
def annotate_queryset(queryset):
"""Add extra information to the queryset."""
queryset = queryset.annotate(line_items=SubqueryCount('lines'))
queryset = queryset.select_related('created_by')
return queryset | Add extra information to the queryset. | annotate_queryset | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def order_fields(extra_fields):
"""Construct a set of fields for this serializer."""
return [
'pk',
'created_by',
'creation_date',
'issue_date',
'start_date',
'target_date',
'description',
'line_items',
... | Construct a set of fields for this serializer. | order_fields | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def clean_line_item(self, line):
"""Clean a line item object (when duplicating)."""
line.pk = None
line.order = self | Clean a line item object (when duplicating). | clean_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def create(self, validated_data):
"""Create a new order object.
Optionally, copy line items from an existing order.
"""
duplicate = validated_data.pop('duplicate', None)
instance = super().create(validated_data)
if duplicate:
order_id = duplicate.get('order... | Create a new order object.
Optionally, copy line items from an existing order.
| create | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def skip_create_fields(self):
"""Skip these fields when instantiating a new object."""
fields = super().skip_create_fields()
return [*fields, 'duplicate'] | Skip these fields when instantiating a new object. | skip_create_fields | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def annotate_queryset(queryset):
"""Add extra information to the queryset.
- Number of lines in the PurchaseOrder
- Overdue status of the PurchaseOrder
"""
queryset = AbstractOrderSerializer.annotate_queryset(queryset)
queryset = queryset.annotate(
completed... | Add extra information to the queryset.
- Number of lines in the PurchaseOrder
- Overdue status of the PurchaseOrder
| annotate_queryset | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def save(self):
"""Save the serializer to 'cancel' the order."""
if not self.order.can_cancel:
raise ValidationError(_('Order cannot be cancelled'))
self.order.cancel_order() | Save the serializer to 'cancel' the order. | save | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def get_context_data(self):
"""Custom context information for this serializer."""
order = self.context['order']
return {'is_complete': order.is_complete} | Custom context information for this serializer. | get_context_data | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def annotate_queryset(queryset):
"""Add some extra annotations to this queryset.
- "total_price" = purchase_price * quantity
- "overdue" status (boolean field)
"""
queryset = queryset.prefetch_related(
Prefetch(
'part__part',
queryset=... | Add some extra annotations to this queryset.
- "total_price" = purchase_price * quantity
- "overdue" status (boolean field)
| annotate_queryset | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate(self, data):
"""Custom validation for the serializer.
- Ensure the supplier_part field is supplied
- Ensure the purchase_order field is supplied
- Ensure that the supplier_part and supplier references match
"""
data = super().validate(data)
supplier... | Custom validation for the serializer.
- Ensure the supplier_part field is supplied
- Ensure the purchase_order field is supplied
- Ensure that the supplier_part and supplier references match
| validate | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate_barcode(self, barcode):
"""Cannot check in a LineItem with a barcode that is already assigned."""
# Ignore empty barcode values
if not barcode or barcode.strip() == '':
return None
barcode_hash = hash_barcode(barcode)
if stock.models.StockItem.lookup_ba... | Cannot check in a LineItem with a barcode that is already assigned. | validate_barcode | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate(self, data):
"""Custom validation for the serializer.
- Integer quantity must be provided for serialized stock
- Validate serial numbers (if provided)
"""
data = super().validate(data)
line_item = data['line_item']
quantity = data['quantity']
... | Custom validation for the serializer.
- Integer quantity must be provided for serialized stock
- Validate serial numbers (if provided)
| validate | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate(self, data):
"""Custom validation for the serializer.
- Ensure line items are provided
- Check that a location is specified
"""
super().validate(data)
order = self.context['order']
items = data.get('items', [])
location = data.get('location... | Custom validation for the serializer.
- Ensure line items are provided
- Check that a location is specified
| validate | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def save(self):
"""Perform the actual database transaction to receive purchase order items."""
data = self.validated_data
request = self.context.get('request')
order = self.context['order']
items = data['items']
# Location can be provided, or default to the order desti... | Perform the actual database transaction to receive purchase order items. | save | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def annotate_queryset(queryset):
"""Add extra information to the queryset.
- Number of line items in the SalesOrder
- Number of completed line items in the SalesOrder
- Overdue status of the SalesOrder
"""
queryset = AbstractOrderSerializer.annotate_queryset(queryset)
... | Add extra information to the queryset.
- Number of line items in the SalesOrder
- Number of completed line items in the SalesOrder
- Overdue status of the SalesOrder
| annotate_queryset | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def __init__(self, *args, **kwargs):
"""Initialization routine for the serializer.
- Add extra related serializer information if required
"""
part_detail = kwargs.pop('part_detail', False)
order_detail = kwargs.pop('order_detail', False)
customer_detail = kwargs.pop('cus... | Initialization routine for the serializer.
- Add extra related serializer information if required
| __init__ | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def annotate_queryset(queryset):
"""Add some extra annotations to this queryset.
- "overdue" status (boolean field)
- "available_quantity"
- "building"
- "on_order"
"""
queryset = queryset.annotate(
overdue=Case(
When(
... | Add some extra annotations to this queryset.
- "overdue" status (boolean field)
- "available_quantity"
- "building"
- "on_order"
| annotate_queryset | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def annotate_queryset(queryset):
"""Annotate the queryset with extra information."""
# Prefetch related objects
queryset = queryset.prefetch_related('order', 'order__customer', 'allocations')
queryset = queryset.annotate(allocated_items=SubqueryCount('allocations'))
return quer... | Annotate the queryset with extra information. | annotate_queryset | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate(self, data):
"""Custom validation for the serializer.
- Ensure the shipment reference is provided
"""
data = super().validate(data)
shipment = self.context.get('shipment', None)
if not shipment:
raise ValidationError(_('No shipment details prov... | Custom validation for the serializer.
- Ensure the shipment reference is provided
| validate | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def save(self):
"""Save the serializer to complete the SalesOrderShipment."""
shipment = self.context.get('shipment', None)
if not shipment:
return
data = self.validated_data
request = self.context.get('request')
user = request.user if request else None
... | Save the serializer to complete the SalesOrderShipment. | save | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate_line_item(self, line_item):
"""Custom validation for the 'line_item' field.
- Ensure the line_item is associated with the particular SalesOrder
"""
order = self.context['order']
# Ensure that the line item points to the correct order
if line_item.order != o... | Custom validation for the 'line_item' field.
- Ensure the line_item is associated with the particular SalesOrder
| validate_line_item | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate_quantity(self, quantity):
"""Custom validation for the 'quantity' field."""
if quantity <= 0:
raise ValidationError(_('Quantity must be positive'))
return quantity | Custom validation for the 'quantity' field. | validate_quantity | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate(self, data):
"""Custom validation for the serializer.
- Ensure that the quantity is 1 for serialized stock
- Quantity cannot exceed the available amount
"""
data = super().validate(data)
stock_item = data['stock_item']
quantity = data['quantity']
... | Custom validation for the serializer.
- Ensure that the quantity is 1 for serialized stock
- Quantity cannot exceed the available amount
| validate | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def get_context_data(self):
"""Custom context data for this serializer."""
order = self.context['order']
return {
'is_complete': order.is_completed(),
'pending_shipments': order.pending_shipment_count,
} | Custom context data for this serializer. | get_context_data | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def save(self):
"""Save the serializer to complete the SalesOrder."""
request = self.context.get('request')
data = self.validated_data
user = request.user if request else None
self.order.ship_order(
user, allow_incomplete_lines=str2bool(data.get('accept_incomplete',... | Save the serializer to complete the SalesOrder. | save | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def get_context_data(self):
"""Add extra context data to the serializer."""
order = self.context['order']
return {'can_cancel': order.can_cancel} | Add extra context data to the serializer. | get_context_data | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate_shipment(self, shipment):
"""Validate the shipment.
- Must point to the same order
- Must not be shipped
"""
order = self.context['order']
if shipment and shipment.shipment_date is not None:
raise ValidationError(_('Shipment has already been shi... | Validate the shipment.
- Must point to the same order
- Must not be shipped
| validate_shipment | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate(self, data):
"""Validation for the serializer.
- Ensure the serial_numbers and quantity fields match
- Check that all serial numbers exist
- Check that the serial numbers are not yet allocated
"""
data = super().validate(data)
line_item = data['line... | Validation for the serializer.
- Ensure the serial_numbers and quantity fields match
- Check that all serial numbers exist
- Check that the serial numbers are not yet allocated
| validate | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def save(self):
"""Allocate stock items against the sales order."""
data = self.validated_data
line_item = data['line_item']
stock_items = data['stock_items']
shipment = data.get('shipment', None)
allocations = []
for stock_item in stock_items:
# Cr... | Allocate stock items against the sales order. | save | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def validate_shipment(self, shipment):
"""Run validation against the provided shipment instance."""
order = self.context['order']
if shipment and shipment.shipment_date is not None:
raise ValidationError(_('Shipment has already been shipped'))
if shipment and shipment.order... | Run validation against the provided shipment instance. | validate_shipment | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def save(self):
"""Perform the allocation of items against this order."""
data = self.validated_data
items = data['items']
shipment = data.get('shipment')
with transaction.atomic():
for entry in items:
# Create a new SalesOrderAllocation
... | Perform the allocation of items against this order. | save | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def annotate_queryset(queryset):
"""Custom annotation for the serializer queryset."""
queryset = AbstractOrderSerializer.annotate_queryset(queryset)
queryset = queryset.annotate(
completed_lines=SubqueryCount(
'lines', filter=~Q(outcome=ReturnOrderLineStatus.PENDING.... | Custom annotation for the serializer queryset. | annotate_queryset | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def save(self):
"""Saving this serializer marks the returned items as received."""
order = self.context['order']
request = self.context.get('request')
data = self.validated_data
items = data['items']
location = data['location']
with transaction.atomic():
... | Saving this serializer marks the returned items as received. | save | python | inventree/InvenTree | src/backend/InvenTree/order/serializers.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/serializers.py | MIT |
def notify_overdue_purchase_order(po: order.models.PurchaseOrder) -> None:
"""Notify users that a PurchaseOrder has just become 'overdue'.
Arguments:
po: The PurchaseOrder object that is overdue.
"""
targets: list[User | Group | Owner] = []
if po.created_by:
targets.append(po.creat... | Notify users that a PurchaseOrder has just become 'overdue'.
Arguments:
po: The PurchaseOrder object that is overdue.
| notify_overdue_purchase_order | python | inventree/InvenTree | src/backend/InvenTree/order/tasks.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/tasks.py | MIT |
def check_overdue_purchase_orders():
"""Check if any outstanding PurchaseOrders have just become overdue.
Rules:
- This check is performed daily
- Look at the 'target_date' of any outstanding PurchaseOrder objects
- If the 'target_date' expired *yesterday* then the order is just out of date
"""... | Check if any outstanding PurchaseOrders have just become overdue.
Rules:
- This check is performed daily
- Look at the 'target_date' of any outstanding PurchaseOrder objects
- If the 'target_date' expired *yesterday* then the order is just out of date
| check_overdue_purchase_orders | python | inventree/InvenTree | src/backend/InvenTree/order/tasks.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/tasks.py | MIT |
def notify_overdue_sales_order(so: order.models.SalesOrder) -> None:
"""Notify appropriate users that a SalesOrder has just become 'overdue'."""
targets: list[User, Group, Owner] = []
if so.created_by:
targets.append(so.created_by)
if so.responsible:
targets.append(so.responsible)
... | Notify appropriate users that a SalesOrder has just become 'overdue'. | notify_overdue_sales_order | python | inventree/InvenTree | src/backend/InvenTree/order/tasks.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/tasks.py | MIT |
def check_overdue_sales_orders():
"""Check if any outstanding SalesOrders have just become overdue.
- This check is performed daily
- Look at the 'target_date' of any outstanding SalesOrder objects
- If the 'target_date' expired *yesterday* then the order is just out of date
"""
yesterday = dat... | Check if any outstanding SalesOrders have just become overdue.
- This check is performed daily
- Look at the 'target_date' of any outstanding SalesOrder objects
- If the 'target_date' expired *yesterday* then the order is just out of date
| check_overdue_sales_orders | python | inventree/InvenTree | src/backend/InvenTree/order/tasks.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/tasks.py | MIT |
def notify_overdue_return_order(ro: order.models.ReturnOrder) -> None:
"""Notify appropriate users that a ReturnOrder has just become 'overdue'."""
targets: list[User, Group, Owner] = []
if ro.created_by:
targets.append(ro.created_by)
if ro.responsible:
targets.append(ro.responsible)
... | Notify appropriate users that a ReturnOrder has just become 'overdue'. | notify_overdue_return_order | python | inventree/InvenTree | src/backend/InvenTree/order/tasks.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/tasks.py | MIT |
def check_overdue_return_orders():
"""Check if any outstanding return orders have just become overdue.
- This check is performed daily
- Look at the 'target_date' of any outstanding return order objects
- If the 'target_date' expired *yesterday* then the order is just out of date
"""
yesterday ... | Check if any outstanding return orders have just become overdue.
- This check is performed daily
- Look at the 'target_date' of any outstanding return order objects
- If the 'target_date' expired *yesterday* then the order is just out of date
| check_overdue_return_orders | python | inventree/InvenTree | src/backend/InvenTree/order/tasks.py | https://github.com/inventree/InvenTree/blob/master/src/backend/InvenTree/order/tasks.py | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.