Changeset 477a34c in tailbone


Ignore:
Timestamp:
07/10/18 14:24:12 (2 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
16ab8b6
Parents:
147c65a
Message:

Improve how cases/units, uom are handled for mobile receiving

last-used uom should be more or less sticky, etc.

Location:
tailbone
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tailbone/static/js/tailbone.mobile.receiving.js

    r147c65a r477a34c  
    6969
    7070
     71// quick-receive (1 CS)
    7172$(document).on('click', 'form.receiving-update .receive-one-case', function() {
    7273    var form = $(this).parents('form:first');
    7374    form.find('[name="mode"]').val('received');
    7475    form.find('[name="cases"]').val('1');
     76    form.find('input[name="quick_receive"]').val('true');
    7577    form.submit();
    7678});
  • tailbone/templates/mobile/receiving/view_row.mako

    r147c65a r477a34c  
    66
    77<%def name="page_title()">${h.link_to("Receiving", url('mobile.receiving'))} &raquo; ${h.link_to(batch.id_str, url('mobile.receiving.view', uuid=batch.uuid))} &raquo; ${row.upc.pretty()}</%def>
    8 
    9 <%
    10    unit_uom = 'LB' if row.product and row.product.weighed else 'EA'
    11 
    12    uom = 'CS'
    13    if row.units_ordered and not row.cases_ordered:
    14        uom = 'EA'
    15 %>
    168
    179
     
    10395    </table>
    10496
     97    ${h.hidden('quick_receive', value='false')}
     98
    10599    ${h.hidden('delete_row', value='false')}
    106100    % if request.has_perm('{}.delete_row'.format(permission_prefix)):
  • tailbone/views/purchasing/receiving.py

    r147c65a r477a34c  
    109109    allow_from_scratch = True
    110110    allow_truck_dump = False
     111
     112    default_uom_is_case = True
    111113
    112114    labels = {
     
    705707                    proposed = existing + self.handler.get_units(cases, units, row.case_quantity)
    706708                    new_cases, new_units = self.handler.calc_best_fit(proposed, row.case_quantity)
    707                     if getattr(row, 'cases_{}'.format(mode)) != new_cases:
     709
     710                    old_cases = getattr(row, 'cases_{}'.format(mode))
     711                    if new_cases and old_cases != new_cases:
    708712                        setattr(row, 'cases_{}'.format(mode), new_cases)
    709                     if getattr(row, 'units_{}'.format(mode)) != new_units:
     713                    elif old_cases and not new_cases:
     714                        setattr(row, 'cases_{}'.format(mode), None)
     715
     716                    old_units = getattr(row, 'units_{}'.format(mode))
     717                    if new_units and old_units != new_units:
    710718                        setattr(row, 'units_{}'.format(mode), new_units)
     719                    elif old_units and not new_units:
     720                        setattr(row, 'units_{}'.format(mode), None)
    711721
    712722                    # if mode in ('damaged', 'expired', 'mispick'):
     
    723733                    self.handler.refresh_row(row)
    724734
     735                    # keep track of last-used uom, although we just track
     736                    # whether or not it was 'CS' since the unit_uom can vary
     737                    sticky_case = None
     738                    if not update_form.validated['quick_receive']:
     739                        if cases and not units:
     740                            sticky_case = True
     741                        elif units and not cases:
     742                            sticky_case = False
     743                    if sticky_case is not None:
     744                        self.request.session['tailbone.mobile.receiving.sticky_uom_is_case'] = sticky_case
     745
    725746                    return self.redirect(self.get_action_url('view', batch, mobile=True))
     747
     748        # unit_uom can vary by product
     749        context['unit_uom'] = 'LB' if row.product and row.product.weighed else 'EA'
     750
     751        # effective uom can vary in a few ways...the basic default is 'CS' if
     752        # self.default_uom_is_case is true, otherwise whatever unit_uom is.
     753        sticky_case = self.request.session.get('tailbone.mobile.receiving.sticky_uom_is_case')
     754        if sticky_case is None:
     755            context['uom'] = 'CS' if self.default_uom_is_case else context['unit_uom']
     756        elif sticky_case:
     757            context['uom'] = 'CS'
     758        else:
     759            context['uom'] = context['unit_uom']
     760        if context['uom'] == 'CS' and row.units_ordered and not row.cases_ordered:
     761            context['uom'] = context['unit_uom']
    726762
    727763        if not row.cases_ordered and not row.units_ordered and not batch.truck_dump:
     
    850886                                          missing=colander.null)
    851887
     888    quick_receive = colander.SchemaNode(colander.Boolean())
     889
    852890    delete_row = colander.SchemaNode(colander.Boolean())
    853891
Note: See TracChangeset for help on using the changeset viewer.