diff --git a/docs/api/index.rst b/docs/api/index.rst index e266e2f51984e08adcbb40e2dcb3bc8b3db7d692..41a4397fdddb2d1f8e6d1a98707b0d534e310d10 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -11,6 +11,7 @@ attributes and method signatures etc. rattail rattail/app + rattail/batch/custorder rattail/batch/handlers rattail/batch/purchase rattail/config diff --git a/docs/api/rattail/batch/custorder.rst b/docs/api/rattail/batch/custorder.rst new file mode 100644 index 0000000000000000000000000000000000000000..84bdfea12f3eb74ce7e21bac5270c544d264a630 --- /dev/null +++ b/docs/api/rattail/batch/custorder.rst @@ -0,0 +1,6 @@ + +``rattail.batch.custorder`` +=========================== + +.. automodule:: rattail.batch.custorder + :members: diff --git a/rattail/batch/custorder.py b/rattail/batch/custorder.py index 913ec47891592a76d2b74fc17c520e61aacf9773..5a11273209bed290b1c5b804f5e3b764a099dc7a 100644 --- a/rattail/batch/custorder.py +++ b/rattail/batch/custorder.py @@ -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: