core.wms

Model.Wms

class anyblok_wms_base.core.wms.Wms[source]

Namespace for WMS related models and transversal methods.

Since this Model does not have any persistent data, making instances of it is mostly irrelevant, and therefore, the transversal methods are classmethods.

Methods

classmethod quantity(goods_type=None, additional_states=None, at_datetime=None, location=None, location_recurse=True, location_tag=<object object>)[source]

Compute the quantity of Goods meeting various criteria.

The computation actually involves querying Avatars, which hold the information about location, states and date/time.

Parameters:
  • goods_type – if specified, restrict computation to Goods of this type
  • location – if specified, restrict computation to Goods Avatars from that location (see also location_recurse below)
  • location_recurse (bool) – If True, and location is specified, the Goods Avatars from sublocations of location will be taken recursively into account.
  • location_tag (str) – If passed, only the Goods Avatars sitting in a Location having or inheriting this tag will be taken into account (may seem only useful if location_recurse is True, yet the non-recursive case behaves consistently).
  • additional_states

    Optionally, states of the Goods Avatar to take into account in addition to the present state.

    Hence, for additional_states=['past'], we have the Goods Avatars that were already there and still are, as well as those that aren’t there any more, and similarly for ‘future’.

  • at_datetime

    take only into account Goods Avatar whose date-time range contains the specified value.

    anyblok_wms_base.constants.DATE_TIME_INFINITY can in particular be used to consider only those Avatars whose dt_until is None.

    This parameter is mandatory if additional_states is specified.

TODO: provide filtering according to Goods properties (should become special PostgreSQL JSON clauses)

TODO: provide a way to add more criteria from optional Bloks, e.g, wms-reservation could add a way to filter only unreserved Goods.

TODO PERF: for timestamp ranges, use GiST indexes and the @> operator. See the comprehensive answer to that question for an entry point. Let’s get a DB with serious volume and datetimes first.

classmethod base_quantity_query()[source]

Return base join query, without any filtering

Returns:The query is assumed to produce exactly one row, with the wished quantity result (possibly None for 0)