Changeset - 16d8bd879a04
[Not reviewed]
0 2 1
Lance Edgar (lance) - 3 years ago 2021-09-09 19:14:39
lance@edbob.org
Add way to customize product autocomplete for new custorder
3 files changed with 24 insertions and 0 deletions:
0 comments (0 inline, 0 general)
docs/api/index.rst
Show inline comments
 
@@ -11,6 +11,7 @@ attributes and method signatures etc.
 

	
 
   rattail
 
   rattail/app
 
   rattail/batch/custorder
 
   rattail/batch/handlers
 
   rattail/batch/purchase
 
   rattail/config
docs/api/rattail/batch/custorder.rst
Show inline comments
 
new file 100644
 

	
 
``rattail.batch.custorder``
 
===========================
 

	
 
.. automodule:: rattail.batch.custorder
 
   :members:
rattail/batch/custorder.py
Show inline comments
 
@@ -39,12 +39,29 @@ class CustomerOrderBatchHandler(BatchHandler):
 
    handler must inspect the
 
    :attr:`~rattail.db.model.batch.custorder.CustomerOrderBatch.mode` attribute
 
    of each batch it deals with, in order to determine which logic to apply.
 

	
 
    .. attribute:: has_custom_product_autocomplete
 

	
 
       If true, this flag indicates that the handler provides custom
 
       autocomplete logic for use when selecting a product while
 
       creating a new order.
 
    """
 
    batch_model_class = model.CustomerOrderBatch
 
    has_custom_product_autocomplete = False
 

	
 
    def get_case_size_for_product(self, product):
 
        return product.case_size
 

	
 
    def custom_product_autocomplete(self, session, term, **kwargs):
 
        """
 
        For the given term, this should return a (possibly empty) list
 
        of products which "match" the term.  Each element in the list
 
        should be a dict with "label" and "value" keys.
 
        """
 
        raise NotImplementedError("Please define the "
 
                                  "{}.custom_product_autocomplete() "
 
                                  "method.".format(__class__.__name__))
 

	
 
    def refresh_row(self, row):
 
        if not row.product:
 
            if row.item_entry:
0 comments (0 inline, 0 general)