Update refactor for editing PO and SO forms

This commit is contained in:
Oliver Walters 2020-05-16 09:36:43 +10:00
parent 8fae32e3c7
commit 08d177e55f
2 changed files with 19 additions and 27 deletions

View File

@ -39,7 +39,7 @@ class HelperForm(forms.ModelForm):
for field in self.fields:
prefix = self.prefix.get(field, None)
suffix = self.suffix.get(field, None)
placeholder = self.placeholder.get(field, None)
placeholder = self.placeholder.get(field, '')
# Look for font-awesome icons
if prefix and prefix.startswith('fa-'):

View File

@ -93,20 +93,16 @@ class EditPurchaseOrderForm(HelperForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.prefix = {
'reference': 'PO',
'link': 'fa-link',
}
# TODO - Refactor this?
self.helper.layout = Layout(
Field(PrependedText(
'reference',
'PO',
placeholder=_("Purchase Order")
)),
Field('supplier'),
Field('supplier_reference'),
Field('description'),
Field('link'),
)
self.placeholder = {
'reference': _('Enter purchase order number'),
}
super().__init__(*args, **kwargs)
class Meta:
model = PurchaseOrder
@ -124,20 +120,16 @@ class EditSalesOrderForm(HelperForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.prefix = {
'reference': 'SO',
'link': 'fa-link',
}
# TODO - Refactor?
self.helper.layout = Layout(
Field(PrependedText(
'reference',
'SO',
placeholder=_("Sales Order")
)),
Field('customer'),
Field('customer_reference'),
Field('description'),
Field('link'),
)
self.placeholder = {
'reference': _('Enter sales order number'),
}
super().__init__(*args, **kwargs)
class Meta:
model = SalesOrder