2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Refactor HelperForm to easily allow setting prepended text / placeholder / etc

This commit is contained in:
Oliver Walters
2020-05-16 09:33:34 +10:00
parent 0ccac09962
commit 8fae32e3c7
2 changed files with 46 additions and 15 deletions

View File

@ -100,8 +100,6 @@ class SerializeStockForm(HelperForm):
# Extract the stock item
item = kwargs.pop('item')
super().__init__(*args, **kwargs)
# Pre-calculate what the serial numbers should be!
sn = item.part.get_next_serial_number()
@ -110,17 +108,15 @@ class SerializeStockForm(HelperForm):
else:
sn = str(sn)
# TODO - Refactor this? Should not have to specify Field('field') for each field...
self.helper.layout = Layout(
Field('quantity'),
Field(PrependedText(
'serial_numbers',
'#',
placeholder=sn
)),
Field('destination'),
Field('note'),
)
self.prefix = {
'serial_numbers': 'fa-hashtag',
}
self.placeholder = {
'serial_numbers': sn
}
super().__init__(*args, **kwargs)
class Meta:
model = StockItem