Improve how cases/units, uom are handled for mobile receiving
last-used uom should be more or less sticky, etc.
This commit is contained in:
parent
147c65afe6
commit
477a34cfa7
3 changed files with 44 additions and 10 deletions
|
@ -109,6 +109,8 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
allow_from_scratch = True
|
||||
allow_truck_dump = False
|
||||
|
||||
default_uom_is_case = True
|
||||
|
||||
labels = {
|
||||
'truck_dump_batch': "Truck Dump Parent",
|
||||
'invoice_parser_key': "Invoice Parser",
|
||||
|
@ -704,10 +706,18 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
existing = getattr(self.handler, 'get_units_{}'.format(mode))(row)
|
||||
proposed = existing + self.handler.get_units(cases, units, row.case_quantity)
|
||||
new_cases, new_units = self.handler.calc_best_fit(proposed, row.case_quantity)
|
||||
if getattr(row, 'cases_{}'.format(mode)) != new_cases:
|
||||
|
||||
old_cases = getattr(row, 'cases_{}'.format(mode))
|
||||
if new_cases and old_cases != new_cases:
|
||||
setattr(row, 'cases_{}'.format(mode), new_cases)
|
||||
if getattr(row, 'units_{}'.format(mode)) != new_units:
|
||||
elif old_cases and not new_cases:
|
||||
setattr(row, 'cases_{}'.format(mode), None)
|
||||
|
||||
old_units = getattr(row, 'units_{}'.format(mode))
|
||||
if new_units and old_units != new_units:
|
||||
setattr(row, 'units_{}'.format(mode), new_units)
|
||||
elif old_units and not new_units:
|
||||
setattr(row, 'units_{}'.format(mode), None)
|
||||
|
||||
# if mode in ('damaged', 'expired', 'mispick'):
|
||||
if mode in ('damaged', 'expired'):
|
||||
|
@ -722,8 +732,34 @@ class ReceivingBatchView(PurchasingBatchView):
|
|||
batch.invoice_total -= row.invoice_total
|
||||
self.handler.refresh_row(row)
|
||||
|
||||
# keep track of last-used uom, although we just track
|
||||
# whether or not it was 'CS' since the unit_uom can vary
|
||||
sticky_case = None
|
||||
if not update_form.validated['quick_receive']:
|
||||
if cases and not units:
|
||||
sticky_case = True
|
||||
elif units and not cases:
|
||||
sticky_case = False
|
||||
if sticky_case is not None:
|
||||
self.request.session['tailbone.mobile.receiving.sticky_uom_is_case'] = sticky_case
|
||||
|
||||
return self.redirect(self.get_action_url('view', batch, mobile=True))
|
||||
|
||||
# unit_uom can vary by product
|
||||
context['unit_uom'] = 'LB' if row.product and row.product.weighed else 'EA'
|
||||
|
||||
# effective uom can vary in a few ways...the basic default is 'CS' if
|
||||
# self.default_uom_is_case is true, otherwise whatever unit_uom is.
|
||||
sticky_case = self.request.session.get('tailbone.mobile.receiving.sticky_uom_is_case')
|
||||
if sticky_case is None:
|
||||
context['uom'] = 'CS' if self.default_uom_is_case else context['unit_uom']
|
||||
elif sticky_case:
|
||||
context['uom'] = 'CS'
|
||||
else:
|
||||
context['uom'] = context['unit_uom']
|
||||
if context['uom'] == 'CS' and row.units_ordered and not row.cases_ordered:
|
||||
context['uom'] = context['unit_uom']
|
||||
|
||||
if not row.cases_ordered and not row.units_ordered and not batch.truck_dump:
|
||||
self.request.session.flash("This item was NOT on the original purchase order.", 'receiving-warning')
|
||||
return self.render_to_response('view_row', context, mobile=True)
|
||||
|
@ -849,6 +885,8 @@ class MobileReceivingForm(colander.MappingSchema):
|
|||
widget=dfwidget.TextInputWidget(),
|
||||
missing=colander.null)
|
||||
|
||||
quick_receive = colander.SchemaNode(colander.Boolean())
|
||||
|
||||
delete_row = colander.SchemaNode(colander.Boolean())
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue