Most Powerful Open Source ERP

Technical Note on Measures and Unit Conversion

Information on unit conversion (from Juliens page)
  • Last Update:2016-06-29
  • Version:001
  • Language:en

Definition of measures and how to use them in ERP5. Notes to help developers get started.

Table of Contents

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):

  • metric_type is a category in the metric_type base category.
  • quantity_unit i is a category in the quantity_unit base category.
  • quantity i 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


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.


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 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:




Describing a resource


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 unit

The first quantity unit of a resource is its management unit.

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/

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.

Querying inventory

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.


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
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)

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.


Related Articles