This script validates Units of Measure (UoM) definitions in Odoo ERP. It checks for correct ratios, categories, and naming conventions.
- Validates compound package names (e.g., "Caja de 12 / Botella de 750 ml")
- Validates simple package names (e.g., "Envase de 750 ml")
- Supports multiple unit types:
- Volume (ml, litros, fl oz, galones, cuartos de galón)
- Weight (gr, oz, libras, kg)
- Length (pulgadas)
- Units (unidades, servicios, porciones)
- Validates conversion ratios against Odoo's reference units
- Handles both larger and smaller units relative to reference units
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Unix/macOS # or venv\Scripts\activate # On Windows
-
Install dependencies:
pip install -r requirements.txt
python check_uom.py -n "Envase de 1 cuarto de galón"python check_uom.py -f uom.uom.csvThe CSV file should have the following columns:
Unidad de medida: UoM nameTipo: UoM type (e.g., "Más grande que la unidad de medida de referencia")Mayor ratio: Ratio for larger unitsRatio: Ratio for smaller unitsTipo de categoría de medida: Category (weight, volume, unit, length)
Note: All values are in Spanish. PRs welcomed for other languages. :)
check_uom.py: Main script with CLI handlingunits.py: Unit definitions and conversion factorsvalidators.py: Core validation logicparsers.py: Functions for parsing unit names and quantities
- Volume: litros
- Weight: libras
- Length: metros
- Units: unidades
Note: Reference units are based on the ones we use. PRs welcomed for other locales. :)