Improve default behavior for receiving a purchase batch

only targeting desktop so far, mobile is next...
This commit is contained in:
Lance Edgar 2018-05-03 18:15:13 -05:00
parent e6144ea08b
commit a5d1eece71
3 changed files with 151 additions and 42 deletions

View file

@ -89,11 +89,38 @@ class ReceivingBatchView(PurchasingBatchView):
model_title_plural = "Receiving Batches"
index_title = "Receiving"
creatable = False
rows_editable = True
rows_deletable = False
mobile_creatable = True
mobile_rows_filterable = True
mobile_rows_creatable = True
form_fields = [
'id',
'store',
'vendor',
'department',
'purchase',
'vendor_email',
'vendor_fax',
'vendor_contact',
'vendor_phone',
'date_ordered',
'date_received',
'po_number',
'po_total',
'invoice_date',
'invoice_number',
'invoice_total',
'notes',
'created',
'created_by',
'status_code',
'complete',
'executed',
'executed_by',
]
mobile_form_fields = [
'vendor',
'department',
@ -116,6 +143,34 @@ class ReceivingBatchView(PurchasingBatchView):
'status_code',
]
row_form_fields = [
'upc',
'item_id',
'product',
'brand_name',
'description',
'size',
'case_quantity',
'cases_ordered',
'units_ordered',
'cases_received',
'units_received',
'cases_damaged',
'units_damaged',
'cases_expired',
'units_expired',
'cases_mispick',
'units_mispick',
'po_line_number',
'po_unit_cost',
'po_total',
'invoice_line_number',
'invoice_unit_cost',
'invoice_total',
'status_code',
'credits',
]
@property
def batch_mode(self):
return self.enum.PURCHASE_BATCH_MODE_RECEIVING
@ -177,8 +232,6 @@ class ReceivingBatchView(PurchasingBatchView):
if mobile:
purchase = self.get_purchase(self.request.POST['purchase'])
kwargs['sms_transaction_number'] = purchase.F1032
numbers = [d.F03 for d in purchase.details]
if numbers:
number = max(set(numbers), key=numbers.count)
@ -186,8 +239,6 @@ class ReceivingBatchView(PurchasingBatchView):
.filter(model.Department.number == number)\
.one()
else:
kwargs['sms_transaction_number'] = batch.sms_transaction_number
return kwargs
def configure_mobile_form(self, f):
@ -199,6 +250,14 @@ class ReceivingBatchView(PurchasingBatchView):
# department
# fs.department.with_renderer(fa.TextFieldRenderer),
def configure_row_form(self, f):
super(ReceivingBatchView, self).configure_row_form(f)
f.set_readonly('cases_ordered')
f.set_readonly('units_ordered')
f.set_readonly('po_unit_cost')
f.set_readonly('po_total')
f.set_readonly('invoice_total')
def render_mobile_row_listitem(self, row, i):
description = row.product.full_description if row.product else row.description
return "({}) {}".format(row.upc.pretty(), description)