コード例 #1
0
ファイル: forms.py プロジェクト: rcludwick/InvenTree
class EditStockItemForm(HelperForm):
    """ Form for editing a StockItem object.
    Note that not all fields can be edited here (even if they can be specified during creation.
    
    location - Must be updated in a 'move' transaction
    quantity - Must be updated in a 'stocktake' transaction
    part - Cannot be edited after creation
    """

    expiry_date = DatePickerFormField(
        help_text=('Expiration date for this stock item'),
    )

    class Meta:
        model = StockItem

        fields = [
            'supplier_part',
            'serial',
            'batch',
            'status',
            'expiry_date',
            'purchase_price',
            'link',
            'delete_on_deplete',
        ]
コード例 #2
0
class EditPurchaseOrderForm(HelperForm):
    """ Form for editing a PurchaseOrder object """

    def __init__(self, *args, **kwargs):

        self.field_prefix = {
            'reference': 'PO',
            'link': 'fa-link',
            'target_date': 'fa-calendar-alt',
        }

        self.field_placeholder = {
            'reference': _('Purchase Order reference'),
        }

        super().__init__(*args, **kwargs)

    target_date = DatePickerFormField(
        help_text=_('Target date for order delivery. Order will be overdue after this date.'),
    )

    class Meta:
        model = PurchaseOrder
        fields = [
            'reference',
            'supplier',
            'supplier_reference',
            'description',
            'target_date',
            'link',
        ]
コード例 #3
0
class EditSalesOrderForm(HelperForm):
    """ Form for editing a SalesOrder object """

    def __init__(self, *args, **kwargs):

        self.field_prefix = {
            'reference': 'SO',
            'link': 'fa-link',
            'target_date': 'fa-calendar-alt',
        }

        self.field_placeholder = {
            'reference': _('Enter sales order number'),
        }

        super().__init__(*args, **kwargs)

    target_date = DatePickerFormField(
        help_text=_('Target date for order completion. Order will be overdue after this date.'),
    )

    class Meta:
        model = SalesOrder
        fields = [
            'reference',
            'customer',
            'customer_reference',
            'description',
            'target_date',
            'link'
        ]
コード例 #4
0
ファイル: forms.py プロジェクト: EUdds/InvenTree
class CreateStockItemForm(HelperForm):
    """ Form for creating a new StockItem """

    expiry_date = DatePickerFormField(
        label=_('Expiry Date'),
        help_text=_('Expiration date for this stock item'),
    )

    serial_numbers = forms.CharField(
        label=_('Serial Numbers'),
        required=False,
        help_text=_('Enter unique serial numbers (or leave blank)'))

    def __init__(self, *args, **kwargs):

        self.field_prefix = {
            'serial_numbers': 'fa-hashtag',
            'link': 'fa-link',
        }

        super().__init__(*args, **kwargs)

    class Meta:
        model = StockItem
        fields = [
            'part',
            'supplier_part',
            'location',
            'quantity',
            'batch',
            'serial_numbers',
            'packaging',
            'purchase_price',
            'expiry_date',
            'link',
            'delete_on_deplete',
            'status',
            'owner',
        ]

    # Custom clean to prevent complex StockItem.clean() logic from running (yet)
    def full_clean(self):
        self._errors = ErrorDict()

        if not self.is_bound:  # Stop further processing.
            return

        self.cleaned_data = {}

        # If the form is permitted to be empty, and none of the form data has
        # changed from the initial data, short circuit any validation.
        if self.empty_permitted and not self.has_changed():
            return

        # Don't run _post_clean() as this will run StockItem.clean()
        self._clean_fields()
        self._clean_form()
コード例 #5
0
class EditBuildForm(HelperForm):
    """ Form for editing a Build object.
    """

    field_prefix = {
        'reference': 'BO',
        'link': 'fa-link',
        'batch': 'fa-layer-group',
        'serial-numbers': 'fa-hashtag',
        'location': 'fa-map-marker-alt',
        'target_date': 'fa-calendar-alt',
    }

    field_placeholder = {
        'reference': _('Build Order reference'),
        'target_date': _('Order target date'),
    }

    target_date = DatePickerFormField(
        label=_('Target Date'),
        help_text=
        _('Target date for build completion. Build will be overdue after this date.'
          ))

    quantity = RoundingDecimalFormField(
        max_digits=10,
        decimal_places=5,
        label=_('Quantity'),
        help_text=_('Number of items to build'))

    class Meta:
        model = Build
        fields = [
            'reference',
            'title',
            'part',
            'quantity',
            'batch',
            'target_date',
            'take_from',
            'destination',
            'parent',
            'sales_order',
            'link',
            'issued_by',
            'responsible',
        ]
コード例 #6
0
ファイル: forms.py プロジェクト: rcludwick/InvenTree
class EditBuildForm(HelperForm):
    """ Form for editing a Build object.
    """

    field_prefix = {
        'reference': 'BO',
        'link': 'fa-link',
        'batch': 'fa-layer-group',
        'serial-numbers': 'fa-hashtag',
        'location': 'fa-map-marker-alt',
        'target_date': 'fa-calendar-alt',
    }

    field_placeholder = {
        'reference': _('Build Order reference'),
        'target_date': _('Order target date'),
    }

    target_date = DatePickerFormField(help_text=_(
        'Target date for build completion. Build will be overdue after this date.'
    ))

    class Meta:
        model = Build
        fields = [
            'reference',
            'title',
            'part',
            'quantity',
            'batch',
            'target_date',
            'take_from',
            'destination',
            'parent',
            'sales_order',
            'link',
        ]