Changeset ad7b347 in tailbone


Ignore:
Timestamp:
07/24/2022 10:29:55 PM (6 months ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
9589606
Parents:
f33d7b7
Message:

Add "auto-receive all items" support for receiving batch API

Location:
tailbone
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tailbone/api/batch/receiving.py

    rf33d7b7 rad7b347  
    33#
    44#  Rattail -- Retail Software Framework
    5 #  Copyright © 2010-2021 Lance Edgar
     5#  Copyright © 2010-2022 Lance Edgar
    66#
    77#  This file is part of Rattail.
     
    7575        data['invoice_total_calculated'] = batch.invoice_total_calculated
    7676
     77        data['can_auto_receive'] = self.handler.can_auto_receive(batch)
     78
    7779        return data
    7880
     
    8284        batch = super(ReceivingBatchViews, self).create_object(data)
    8385        return batch
     86
     87    def auto_receive(self):
     88        """
     89        View which handles auto-marking as received, all items within
     90        a pending batch.
     91        """
     92        batch = self.get_object()
     93        self.handler.auto_receive_all_items(batch)
     94        return self._get(obj=batch)
    8495
    8596    def mark_receiving_complete(self):
     
    136147        collection_url_prefix = cls.get_collection_url_prefix()
    137148        object_url_prefix = cls.get_object_url_prefix()
     149
     150        # auto-receive
     151        config.add_route('{}.auto_receive'.format(route_prefix),
     152                         '{}/{{uuid}}/auto-receive'.format(object_url_prefix))
     153        config.add_view(cls, attr='auto_receive',
     154                        route_name='{}.auto_receive'.format(route_prefix),
     155                        permission='{}.auto_receive'.format(permission_prefix),
     156                        renderer='json')
    138157
    139158        # mark receiving complete
  • tailbone/templates/receiving/configure.mako

    rf33d7b7 rad7b347  
    130130    </b-field>
    131131
    132     <b-field>
     132    <b-field message="If set, one or more &quot;quick receive&quot; buttons will be available for mobile receiving.">
    133133      <b-checkbox name="rattail.batch.purchase.mobile_quick_receive"
    134134                  v-model="simpleSettings['rattail.batch.purchase.mobile_quick_receive']"
     
    139139    </b-field>
    140140
    141     <b-field>
     141    <b-field message="If set, only a &quot;quick receive all&quot; button will be shown.  Only applicable if quick receive (above) is enabled.">
    142142      <b-checkbox name="rattail.batch.purchase.mobile_quick_receive_all"
    143143                  v-model="simpleSettings['rattail.batch.purchase.mobile_quick_receive_all']"
    144144                  native-value="true"
    145145                  @input="settingsNeedSaved = true">
    146         Allow "Quick Receive All"
     146        Quick Receive "All or Nothing"
    147147      </b-checkbox>
    148148    </b-field>
  • tailbone/views/purchasing/receiving.py

    rf33d7b7 rad7b347  
    130130        'vendor_phone',
    131131        'date_ordered',
    132         'date_received',
    133132        'po_number',
    134133        'po_total',
     134        'date_received',
    135135        'invoice_date',
    136136        'invoice_number',
     
    18251825
    18261826    def can_auto_receive(self, batch):
    1827         if batch.executed:
    1828             return False
    1829         if batch.complete:
    1830             return False
    1831 
    1832         if batch.is_truck_dump_related():
    1833             if not batch.is_truck_dump_parent():
    1834                 return False
    1835             if not batch.truck_dump_children_first():
    1836                 return False
    1837 
    1838         # only auto-receive once per batch
    1839         if batch.get_param('auto_received'):
    1840             return False
    1841 
    1842         return True
     1827        return self.handler.can_auto_receive(batch)
    18431828
    18441829    def auto_receive(self):
     
    18661851        session = RattailSession()
    18671852        batch = session.query(model.PurchaseBatch).get(uuid)
    1868         user = session.query(model.User).get(user_uuid)
     1853        # user = session.query(model.User).get(user_uuid)
    18691854        try:
    18701855            self.handler.auto_receive_all_items(batch, progress=progress)
Note: See TracChangeset for help on using the changeset viewer.