How to showing how to specify the magnitude of an attribute of a resource (like the weight of a product).
Table of Contents
What are Measures?¶
A measure allows to specify the magnitude (quantity * quantity_unit) of some
attribute (metric_type¶) of a resource (ex: Product, Service...), such as its
length or mass. Thus, an amount of a resource can be expressed according to any
of its metric types. For example, the weight of a product is 5kg.
A measure is defined on a resource and is roughly a triplet (metric_type¶,
quantity_unit, quantity):
- metric_type¶ is a category in the metric_type base category.
- quantity_unit¶ is a category in the quantity_unit base category.
- quantity is a float, expressed in the unit quantity_unit.
A measure describes a resource in respect to 1 management unit of the resource.
Setting up categories¶
quantity_unit¶
The quantity_unit¶ base category is a database of measurement units.
It is filled independently from any resource. Units used for a given physical
quantity are grouped in the same subcategory, so we have the following schema:
quantity_unit/<physical_quantity>/<unit>
Each unit has a quantity property containing the ratio in respect to a base
unit (of the same physical quantity). The ratio must be 1 for a base one. /!\
Since r31858 the usage of quantity property is deprecated. Please see the Setting
up Quantity Unit Conversion Module section below.
Example¶:
- quantity_unit¶/unit/unit (quantity = 1)
- quantity_unit¶/unit/dozen (quantity = 12)
- quantity_unit¶/mass/lb (quantity = .45359237)
- quantity_unit¶/mass/g (quantity = .001)
- quantity_unit¶/mass/kg (quantity = 1)
metric_type¶
metric_type¶ is a base category defining any attribute a resource might have.
The schema must be similar to quantity_unit so that it is possible to determine
relevant units for each metric type:
metric_type/<physical_quantity>/...
Example¶:
- metric_type¶/mass/net_weight
- metric_type¶/mass/dry_weight
- metric_type¶/unit/food/egg
- metric_type¶/volume
Setting up Quantity Unit Conversion Module¶
Go to the Unit Conversions module. Here, you will define a base quantity for each
quantity_unit¶/<physical_quantity>
category and define the ratios between
quantities of that category.
Example¶ to set up kilgrams and grams:
- Create a "Quantity Unit Conversion Group".
- Set the quantity unit as quantity_unit/mass/kg. This means that the current group will define all quantity_unit/mass/* ratios with regard to mass/kg.
- Create a "Quantity Unit Conversion Definition"
- Set up Quantity Unit as quantity_unit/mass/g.
- Set up quantity as 0.001: this means that you define a gram as 0.001 kilograms.
If you were to define the mass/ton unit, you would use the same Quantity Unit
Conversion Group. If the physical unit is different (e.g. volume/liter),
you would create a new Group.
Describing a Resource¶
Measures¶
A measure object must be added to a resource for any metric type you want to describe.
To add a measure:
- Select Add Measure from the Action menu.
- Select a metric type.
- Save to update the list of possible quantity units.
- Fill the remaining fields (see next section for the Default Metric Type setting)
Variations are supported: When the resource is variated, you can choose according
to which base category the measure is variated. From the Measure tab of a
resource, you can see the measures in a listbox. You can also edit them directly.
Quantity Units¶
Default Measures¶
Only specifying 'quantity * quantity_unit'
is not enough to represent an amount
of resource. In principle, a metric type should also be given, because a resource
may have several metric types using the same physical quantity.
For example, the gram could represent either the "gross weight" or the "net weight"
of a resource. Since there are places in ERP5 where you can only choose a quantity
unit, there is a way to associate a default measure to each physical quantity,
thanks to the Default Metric Type setting of a measure.
Management Units¶
The first quantity unit of a resource is its management unit. On cataloging, an
implicit measure is created for the management unit, in case there isn't any.
The metric type used for such a measure is a generic one, i.e. metric_type¶/<physical_quantity>
If you want to manage a resource according to a specific metric type, you must
create a measure for the management unit, with the following restriction:
- 'quantity * quantity_unit' must match the management unit: simply set quantity to 1 and quantity_unit to the management unit.
- The measure mustn't be variated.
- Then, check Default Metric Type.
Note:The validation of a resource will check that all measures
and units are consistent. However, constraints on resources are disabled by
default: you must add the ResourceContraint property sheet on portal types
for which you want checking to be done.
Querying Stock¶
From a resource module page, a Converted Inventory Report is available:
- Select several resources.
- Click on the report button.
- Select a metric type and a quantity unit.
- Submit: you get the inventory per node, for all simulation periods, for the selected resources, metric types and quantity units.
Only metric types common to all selected resources can be chosen.
Example¶
Let's given a box of 12 eggs, knowing that there are several sizes of eggs:
- small (S): less than 53 g
- medium (M): between 53 and 63 g
- big (L): between 63 and 73 g
- very big (XL): more than 73 g
Create the following measure for the net weight:
- metric_type¶: mass/net_weight
- default_metric_type: yes
- quantity_unit¶: mass/g
- variation axes: size
- matrix:
- S: 576 (48*12)
- M: 696 (58*12)
- L: 816 (68*12)
- XL: 936 (78*12)
Do the same for the gross weight:
- metric_type¶: mass
- default_metric_type: no
- variation axes: size
- ...
For the number of eggs per box:
- metric_type¶: unit/food/egg
- default_metric_type: no
- quantity_unit¶: unit/dozen
- quantity: 1
Set the following quantity units to the resource:
- unit/unit (management unit)
- mass/g
- mass/lb
When buying boxes of eggs, you can specify the quantity of boxes in:
- unit/unit: quantity is a number of boxes of 12 eggs.
- mass/g: quantity is the net weight (in grams) of the amount of eggs
- mass/lb: net weight, in pounds.
You can also know the number of eggs in all nodes:
- From the Product Module page, select the boxes of eggs.
- Click on the report button for a Converted Inventory Report.
- Choose metric_type/unit/food/egg and quantity_unit/unit/unit.
- Submit.
References & Examples¶
See also:
Related Articles¶