Repository navigation
Expand file tree
/
Copy pathforms.py
More file actions
49 lines (38 loc) · 1.38 KB
/
Copy pathforms.py
File metadata and controls
49 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""Django Forms for interacting with Part objects."""
from django import forms
from django.utils.translation import gettext_lazy as _
from common.forms import MatchItemForm
from InvenTree.helpers import clean_decimal
from .models import Part
class BomMatchItemForm(MatchItemForm):
"""Override MatchItemForm fields."""
def get_special_field(self, col_guess, row, file_manager):
"""Set special fields."""
# set quantity field
if 'quantity' in col_guess.lower():
return forms.CharField(
required=False,
widget=forms.NumberInput(attrs={
'name': 'quantity' + str(row['index']),
'class': 'numberinput',
'type': 'number',
'min': '0',
'step': 'any',
'value': clean_decimal(row.get('quantity', '')),
})
)
return super().get_special_field(col_guess, row, file_manager)
class PartPriceForm(forms.Form):
"""Simple form for viewing part pricing information."""
class Meta:
"""Metaclass defines fields for this form"""
model = Part
fields = [
'quantity',
]
quantity = forms.IntegerField(
required=True,
initial=1,
label=_('Quantity'),
help_text=_('Input quantity for price calculation')
)