How To Use Measures (Unit Conversion)

What's a measure

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.

A measure is defined on a resource and is roughly a triplet (metric_type, quantity_unit, quantity):

A measure describes a resource in respect to 1 management unit of the resource.

Setting up categories


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:

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.



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:


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:

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


A measure object must be added to a resource for any metric type you want to describe.

To add a measure:

  1. Select Add Measure from the Action menu.

  2. Select a metric type.
  3. Save to update the list of possible quantity units.
  4. 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 unit

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:

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:

  1. Select several resources.
  2. Click on the report button.
  3. Select a metric type and a quantity unit.
  4. 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.


Let's given a box of 12 eggs, knowing that there are several sizes of eggs:

Create the following measure for the net weight:

Do the same for the gross weight:

For the number of eggs per box:

Set the following quantity units to the resource:

  1. unit/unit (management unit)
  2. mass/g
  3. mass/lb

When buying boxes of eggs, you can specify the quantity of boxes in:

You can also know the number of eggs in all nodes:

  1. From the Product Module page, select the boxes of eggs.
  2. Click on the report button for a Converted Inventory Report.

  3. Choose metric_type/unit/food/egg and quantity_unit/unit/unit.

  4. Submit.

See also

HowToUseMeasures (last edited 2010-01-25 05:42:31 by NicolasDumazet)