rattail.batch.product

Handler for generic product batches

class rattail.batch.product.ProductBatchHandler(config, **kwargs)[source]

Handler for generic product batches.

batch_model_class

alias of ProductBatch

describe_execution(batch, **kwargs)[source]

This method should essentially return some text describing briefly what will happen when the given batch is executed.

Parameters:

batch – The batch in question, which is a candidate for execution.

Returns:

String value describing the batch execution.

execute(batch, user=None, action='make_label_batch', progress=None, **kwargs)[source]

Execute the given batch, according to the given kwargs. This is really where the magic happens, although each handler must define that magic, since the default logic does nothing at all.

Note that callers should not use this method, but custom batch handlers should override this method. Conversely, custom handlers should not override the do_execute() method, but callers should use that one directly.

make_label_batch(product_batch, user, progress=None, **kwargs)[source]

Make a new Label Batch from the given Product Batch.

Parameters:
  • product_batch – Reference to a ProductBatch instance from which a new label batch should be made.

  • userUser who is responsible for this action.

Returns:

A new LabelBatch instance, populated from the given product batch.

make_pricing_batch(product_batch, user, progress=None, **kwargs)[source]

Make a new Pricing Batch from the given Product Batch.

Parameters:
  • product_batch – Reference to a ProductBatch instance from which a new pricing batch should be made.

  • userUser who is responsible for this action.

Returns:

A new PricingBatch instance, populated from the given product batch.

populate(batch, progress=None)[source]

Populate the batch with initial data rows. It is assumed that the data source to be used will be known by inspecting various properties of the batch itself.

Note that callers should not use this method, but custom batch handlers should override this method. Conversely, custom handlers should not override the do_populate() method, but callers should use that one directly.

refresh_row(row)[source]

This method will be passed a row object which has already been properly added to a batch, and which has basic required fields already populated. This method is then responsible for further populating all applicable fields for the row, based on current data within the appropriate system(s).

Note that in some cases this method may be called multiple times for the same row, e.g. once when first creating the batch and then later when a user explicitly refreshes the batch. The method logic must account for this possibility.

should_populate(batch)[source]

Must return a boolean indicating whether the given batch should be populated from an initial data source, i.e. at time of batch creation. Override this method if you need to inspect the batch in order to determine whether the populate step is needed. Default behavior is to simply return the value of populate_batches.