Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: ADR Dangerous Goods

Entity: stock.move

Compute Method: _compute_adr_points

Inputs Method Outputs
  • product_id
  • product_id.adr_goods_id
  • product_id.weight
  • product_uom_qty
  • product_uom
  • product_uom.factor
"""Compute the normalized ADR points

        Set the ADR points for the weight or quantity of the given moves,
        multiplied by the factor derived from their UN number or transport category.
        """
precision = self.env["decimal.precision"].precision_get(
            "Product Unit of Measure"
        )
for sm in self:
            if not sm.product_id.adr_goods_id:
                sm.adr_points = 0
                continue
            adr_goods = sm.product_id.adr_goods_id
            if sm.product_id.weight:
                # Assume that the product weight is in kilos per unit
                reference_qty = sm.product_id.weight * sm.product_uom_qty
            else:
                # Conflate the reference unit (kilo, liter) with the ADR unit
                reference_qty = sm.product_uom_qty / sm.product_uom.factor
            adr_factor = un_number_points_factor_map.get(
                adr_goods.un_number,
                category_points_factor_map.get(adr_goods.transport_category, 0),
            )
            sm.adr_points = float_round(adr_factor * reference_qty, precision)

Back to entity