Discover powerful Dolibarr extensions designed to automate your business processes

1. Overview
DoliChocolat turns Dolibarr into a vertical ERP for artisanal and industrial chocolate factories. It covers the whole business chain from the cocoa bean to the end customer: sourcing, cocoa processing, recipes and formulation, production (MES/GPAO), tempering, moulding, enrobing, packaging, quality, laboratory, HACCP, traceability, stock, maintenance (CMMS), energy, costing and performance analysis — with no external software.
Technical profile
· Dolibarr 16.0+ (validated on 17.0.3); PHP 7.1 minimum, PHP 8.x compatible; MySQL/MariaDB.
· Module number 523800, rights class 'dolichocolat', family 'products'.
· Dependencies: modSociete (Third parties) and modProduct (Products).
· 24 business objects, 24 SQL tables, 23 permissions in 9 groups, 31 menu entries.
· 5 languages: French, English, Italian, German, Spanish (595 keys each).
· Object-oriented: every object extends CommonObject and uses createCommon/fetchCommon/updateCommon/deleteCommon.
· REST API, scheduled job (cron), boxes, extrafields-ready, GED and multi-entity support.
2. Architecture
The module follows the official Dolibarr external-module layout and is generated from a single field specification, which keeps the SQL schema, the PHP classes, the list/card pages and the language files structurally in sync.
|
Path |
Responsibility |
|
core/modules/modDoliChocolat.class.php |
Module descriptor: number, rights, menus, constants, boxes, cron job, init()/remove(). |
|
class/<object>.class.php |
One CommonObject subclass per business object (24), with $fields, create/fetch/update/delete, getNomUrl and getLibStatut. |
|
class/dolichocolatsampledata.class.php |
Demonstration dataset generator and purge (import_key tagged, versioned). |
|
class/dolichocolatcron.class.php |
Scheduled job: recompute yields, late orders, machine availability and HACCP deviations. |
|
class/api_dolichocolat.class.php |
REST API (Restler): list, read, create, update, delete and the traceability endpoint. |
|
lib/dolichocolat.lib.php |
Shared helpers: registry access, permissions, vocabularies, KPI card renderer, schema self-heal. |
|
lib/dolichocolat_objects.php |
Generated object registry: class, table, picto, menu label, fields, hub/lines relations. |
|
lib/dolichocolat_menu.php |
Menu synchronisation helper and the in-page tab bar. |
|
objectlist.inc.php / objectcard.inc.php |
Generic list and card engines driven by the registry. |
|
<object>_list.php / <object>_card.php |
Thin stubs setting $dch_object_key and including the generic engine. |
|
dashboard.php |
Chocolate-charter dashboard: KPI cards, gauges, charts, alerts, kanban, timeline. |
|
reporting.php |
16 reports with PDF / Excel / Word / CSV export. |
|
traceability.php / haccp.php / ai.php |
Bespoke pages: traceability chain, HACCP cockpit, AI workspace. |
|
admin/setup.php / admin/about.php |
Configuration page and about page. |
|
sql/llx_dch_*.sql |
Table definitions and indexes (24 tables). |
|
langs/<lang>/dolichocolat.lang |
Language files (fr_FR, en_US, es_ES, it_IT, de_DE). |
|
css/dolichocolat.css.php / js/dolichocolat.js.php |
Module stylesheet (chocolate charter) and script, injected via module_parts. |
Design decisions
· Every language key is prefixed 'Dch'. Dolibarr merges all active modules' language files into a single tab_translate and the last loaded value wins, so unprefixed generic keys (Ref, Qty, Note, Machine) silently render another module's wording. The prefix removes the collision surface instead of fighting it at runtime.
· table_element carries no llx_ prefix; the live prefix comes from $db->prefix().
· ensureSchema() runs after _load_tables(): Dolibarr only CREATEs tables and never ALTERs them, so new columns are added on upgrade by parsing the SQL files.
· Menu positions use a module-unique high base (100000) and every URL is module-local, so the (menu_handler, fk_menu, position, url, entity) dedup key cannot collide with another module.
· Costs and margins ignore rows without both a sale price and a cost: a missing value is unknown, not zero.
3. Data model and SQL tables
24 tables, all prefixed llx_dch_. Every table shares the same technical envelope: rowid (auto-increment PK), entity (multi-company), status, date_creation, tms, fk_user_creat, fk_user_modif and import_key (used to tag and purge demonstration data). Column counts below are read from the live schema.
|
Table |
Object |
Cols |
Purpose |
|
llx_dch_supplier |
Cocoa supplier |
21 |
Supplier of cocoa or ingredients: origin country/region, plantation, certification, quality score, average price per kg. Linked to llx_societe. |
|
llx_dch_bean |
Cocoa bean |
24 |
Bean reference: variety (Criollo/Forastero/Trinitario), origin, harvest year, fermentation days, humidity, fat content, aroma profile, stock. |
|
llx_dch_material |
Raw material |
25 |
Cocoa mass/butter/powder, sugar, milk, nuts, aromas, additives, packaging. Carries lot number, DLC, allergens, cost/kg, stock and alert threshold. |
|
llx_dch_reception |
Goods reception |
25 |
Inbound reception with announced/received quantity, gross/net weight, humidity, temperature and control verdict. |
|
llx_dch_recipe |
Chocolate recipe |
32 |
Versioned recipe: chocolate type, cocoa/sugar/butter/milk percentages, process, conching, tempering curve, yield, cost, allergens, nutrition. Linked to llx_product. |
|
llx_dch_recipe_line |
Recipe composition line |
16 |
One raw material in a recipe: dosage, unit, share of batch, line cost, allergen flag. Child of llx_dch_recipe. |
|
llx_dch_formulation |
Formulation / simulation |
21 |
Cost simulation of a recipe variant: batch size, target cocoa, simulated vs reference cost, deviation, optimization goal. |
|
llx_dch_machine |
Machine |
25 |
Grinder, mixer, refiner, conche, temperer, cooling tunnel, moulding, enrober, packaging line. Carries capacity, power, OEE, availability, MTBF, MTTR. |
|
llx_dch_line |
Production line |
18 |
Workshop line with nominal capacity, operators, OEE and yield. |
|
llx_dch_order |
Production order |
30 |
The GPAO hub: recipe, line, status, priority, planned/produced/scrap quantities, yield, dates, lot number and cost breakdown. |
|
llx_dch_operation |
Routing operation |
20 |
One step of the chocolate cycle for a production order: step code, rank, machine, temperature, duration, operator. Child of llx_dch_order. |
|
llx_dch_tempering |
Tempering record |
23 |
Tempering curve (melting/cooling/working temperatures), temper index, gloss and snap scores, verdict. |
|
llx_dch_moulding |
Moulding record |
23 |
Mould, format, unit weight, moulded/ok/reject quantities, cadence, losses, yield, cooling time. |
|
llx_dch_enrobing |
Enrobing / filling / decoration |
22 |
Step type, coating, filling, decoration, temperature, thickness, treated/reject quantities, consumption. |
|
llx_dch_packaging |
Packaging record |
23 |
Packaging type, format, label, units, units per box, boxes, boxes per pallet, pallets, packaging consumed. |
|
llx_dch_lot |
Finished product lot |
22 |
Traceability pivot: lot number, production order, product, quantities, production date, DLC/DDM, status, blocking reason. |
|
llx_dch_trace |
Traceability event |
20 |
One upstream / internal / downstream link between a supplier, a material, a lot, a production order and a customer. |
|
llx_dch_quality |
Quality control |
23 |
Control at reception/production/finished/shipping: criterion, measured value, min/max limits, unit, verdict. |
|
llx_dch_nonconformity |
Non-conformity / CAPA |
26 |
Type, severity, detection, description, root cause, corrective and preventive action, cost impact, status. |
|
llx_dch_lab |
Laboratory analysis |
29 |
Humidity, fat, particle size, viscosity, gloss/texture/taste/aroma scores, sensory total, microbiology, salmonella. |
|
llx_dch_haccp |
HACCP point |
26 |
CCP / PRP / PRPo: process step, hazard type, critical limit, monitoring, frequency, last value, status. |
|
llx_dch_maintenance |
Maintenance intervention |
25 |
Preventive/corrective/predictive: failure type, dates, duration, downtime, spare parts, costs, status. |
|
llx_dch_energy |
Energy record |
22 |
Electricity/gas/water/industrial cooling per workshop and machine: consumption, unit price, total cost, CO2, kWh per ton. |
|
llx_dch_ai_insight |
AI insight |
23 |
Forecast / anomaly / optimization: domain, period, predicted vs actual value, deviation, confidence, severity, recommendation. |
Key relations
· dch_bean.fk_supplier -> dch_supplier; dch_reception.fk_supplier/fk_material/fk_bean.
· dch_recipe_line.fk_recipe -> dch_recipe (composition lines); dch_formulation.fk_recipe -> dch_recipe.
· dch_order.fk_recipe -> dch_recipe; dch_order.fk_line -> dch_line; dch_operation.fk_order -> dch_order.
· dch_tempering / dch_moulding / dch_enrobing / dch_packaging .fk_order -> dch_order.
· dch_lot.fk_order -> dch_order; dch_lot.fk_product -> llx_product; dch_packaging.fk_lot -> dch_lot.
· dch_trace.fk_lot -> dch_lot, .fk_material -> dch_material, .fk_supplier -> dch_supplier, .fk_soc -> llx_societe.
· dch_quality / dch_lab / dch_nonconformity .fk_lot -> dch_lot and .fk_order -> dch_order.
· dch_maintenance.fk_machine -> dch_machine; dch_energy.fk_machine -> dch_machine, .fk_line -> dch_line.
· Native links: dch_supplier.fk_soc and dch_material.fk_soc -> llx_societe; dch_recipe.fk_product and dch_lot.fk_product -> llx_product; dch_reception.fk_warehouse and dch_lot.fk_warehouse -> llx_entrepot.
4. Features
|
Area |
Capability |
|
Referentials |
Cocoa suppliers with origin and certification; cocoa beans by variety (Criollo, Forastero, Trinitario) with fermentation, humidity, fat and aroma profile; raw materials with lot, DLC, allergens, cost and alert threshold; receptions with weighing and control. |
|
Recipes & formulation |
Versioned recipes with dosed composition, process, conching, tempering curve, yield, cost, allergens and nutrition; validation workflow; formulation with cost simulation, comparison and optimization goal. |
|
Production (GPAO/MES) |
Planning, production orders, routing operations over the 13-step chocolate cycle, machines, lines and operators; per-order cost breakdown (material, labour, energy). |
|
Tempering |
Curves, melting/cooling/working temperatures, temper index, gloss and snap scoring. |
|
Moulding & packaging |
Moulds, formats, cadences, losses, rejects, yield; packaging, labels, boxes, pallets and packaging consumption. |
|
Lots & traceability |
Finished-product lots with DLC/DDM and status; one-click upstream, internal and downstream traceability searchable by lot, product, customer, supplier, date or order. |
|
Quality, lab & HACCP |
Controls at four stages; non-conformities with CAPA; laboratory analyses (humidity, particle size, viscosity, gloss, texture, sensory, microbiology); HACCP plan with CCP/PRP/PRPo, critical limits, monitoring and deviation alerts. |
|
CMMS & energy |
Preventive/corrective/predictive maintenance, spare parts, costs, MTBF, MTTR, availability; electricity, gas, water and industrial cooling with cost and CO2. |
|
Artificial intelligence |
Local statistical engine (no data leaves the server): natural-language business assistant, forecasts, optimization proposals and anomaly detection. |
|
Dashboard & reporting |
Chocolate-charter dashboard with KPI cards, gauges, 8 charts, smart alerts, kanban and production timeline; 16 reports exportable to PDF, Excel, Word and CSV. |
5. Workflows
5.1 Manufacturing cycle
Material preparation -> Mixing -> Refining -> Conching -> Tempering -> Moulding -> Cooling -> Demoulding -> Enrobing -> Filling -> Decoration -> Packaging -> Finished-goods storage. Steps that do not apply to a chocolate family are skipped automatically (a plain bar has no filling or decoration step).
5.2 Production order lifecycle
planned -> running -> done, with late and cancelled as terminal deviations. The scheduled job moves a 'planned' order whose planned date is in the past to 'late'. On completion, yield is recomputed as produced / planned.
5.3 Lot lifecycle
A finished order produces a lot: released, quarantine, blocked, shipped or consumed. A blocked or quarantined lot carries its reason and is raised on the dashboard as a smart alert.
5.4 Non-conformity / CAPA
open -> analysis -> action -> closed, capturing root cause, corrective action, preventive action, impacted quantity and financial impact.
5.5 HACCP monitoring
Each CCP/PRPo carries a critical limit. The scheduled job compares the last recorded value against the band and flags 'deviation' or 'ok'; deviations appear at the top of the HACCP cockpit and on the dashboard.
5.6 Traceability construction
Traceability events are written as the chain progresses: upstream events link supplier and material lots to the production order; the internal event links the order to the finished product; downstream events link the lot to the customer delivery. The traceability page reassembles the three chains for any lot in one click.
6. REST API
The module exposes a Restler API. The URL segment is the lowercased class name, so all routes live under /api/index.php/dolichocolat/. Authentication uses the standard Dolibarr DOLAPIKEY header; an invalid key returns 401. Every route is guarded by the matching right group, and sort fields are whitelisted against the real table columns.
|
Verb |
Route |
Right |
Description |
|
GET |
indicators |
reporting/read |
Key indicators: production today/total, running and late orders, yield, OEE, conformity, blocked lots, HACCP deviations, cocoa stock. |
|
GET |
suppliers |
referential/read |
List cocoa suppliers. |
|
GET |
beans |
referential/read |
List cocoa beans. |
|
GET |
materials |
referential/read |
List raw materials. |
|
GET |
recipes |
recipe/read |
List chocolate recipes. |
|
GET |
orders |
production/read |
List production orders. |
|
GET |
orders/{id} |
production/read |
Read one production order. |
|
POST |
orders |
production/write |
Create a production order. |
|
PUT |
orders/{id} |
production/write |
Update a production order. |
|
DELETE |
orders/{id} |
production/delete |
Delete a production order. |
|
GET |
lots |
traceability/read |
List finished product lots. |
|
GET |
lots/{id}/traceability |
traceability/read |
Full traceability chain of a lot: upstream, internal and downstream events. |
|
GET |
machines |
maintenance/read |
List machines with OEE, availability, MTBF and MTTR. |
|
GET |
qualitycontrols |
quality/read |
List quality controls. |
|
POST |
qualitycontrols |
quality/write |
Record a quality measurement; conformity is derived from the declared tolerance band when not supplied. |
|
GET |
haccp |
quality/read |
List HACCP points. |
Example
curl -H "DOLAPIKEY: <key>" https://<host>/api/index.php/dolichocolat/indicators
{"production_today":2285.9,"production_total":15628.6,"orders_running":10,"orders_late":3,"yield_pct":93.9,"oee_pct":89.4,"conformity_pct":94.5,"blocked_lots":4,"haccp_deviations":1,"stock_cacao_kg":21812}
7. Integrations
· Third parties (llx_societe): cocoa suppliers and chocolate customers.
· Products (llx_product): finished goods linked to recipes and lots; the product sale price feeds the margin KPI.
· Stock and warehouses (llx_entrepot): receptions and lots reference native warehouses.
· Sales cycle: quotations, customer orders, invoices, supplier orders, receptions and shipments reachable from the module objects.
· Accounting and analytic accounting: production costs are exposed per order for downstream posting.
· Projects and Agenda: standard Dolibarr links on module objects.
· GED (ECM): document storage on module objects.
· REST API and cron as described above.
· Boxes: a dashboard widget exposes production today, running orders, yield, OEE, conformity, blocked lots and HACCP alerts.
· Multi-entity: every table carries `entity` and queries use getEntity(), so the module is multi-company ready.
8. Permissions
23 permissions. Read and write are granted by default so the module is usable immediately after activation; delete and admin are not.
|
Group |
Actions |
Scope |
|
referential |
read / write / delete |
Suppliers, beans, materials, receptions |
|
recipe |
read / write / delete |
Recipes and formulations |
|
production |
read / write / delete |
Production orders, tempering, moulding, enrobing, packaging |
|
traceability |
read / write / delete |
Lots and traceability events |
|
quality |
read / write / delete |
Quality controls, non-conformities, laboratory, HACCP |
|
maintenance |
read / write / delete |
Machines and CMMS maintenance |
|
energy |
read / write / delete |
Energy management |
|
reporting |
read |
Reporting, analytics and artificial intelligence |
|
admin |
- |
Module administration |
9. Configuration constants
|
Constant |
Default |
Purpose |
|
DOLICHOCOLAT_EXPIRY_ALERT_DAYS |
30 |
Days before DLC that raise an expiry alert |
|
DOLICHOCOLAT_LOW_STOCK_THRESHOLD |
5 |
Low-stock alert threshold |
|
DOLICHOCOLAT_TARGET_YIELD |
95 |
Target production yield (percent) |
|
DOLICHOCOLAT_TARGET_OEE |
85 |
Target OEE (percent) |
|
DOLICHOCOLAT_ENERGY_PRICE |
0.18 |
Average kWh price |
|
DOLICHOCOLAT_LABOR_COST_HOUR |
32 |
Hourly labour cost |
|
DOLICHOCOLAT_LOT_PREFIX |
LOT |
Lot number prefix |
|
DOLICHOCOLAT_SHELF_LIFE_DAYS |
365 |
Default finished-product shelf life (days) |
|
DOLICHOCOLAT_ENABLE_HACCP |
1 |
Enable the HACCP module |
|
DOLICHOCOLAT_ENABLE_LAB |
1 |
Enable the laboratory |
|
DOLICHOCOLAT_ENABLE_AI |
1 |
Enable artificial intelligence |
|
DOLICHOCOLAT_ENABLE_ENERGY |
1 |
Enable energy monitoring |
|
DOLICHOCOLAT_ENABLE_GMAO |
1 |
Enable the CMMS |
|
DOLICHOCOLAT_SAMPLE_DATA_DONE |
- |
Demonstration dataset version guard |
10. Demonstration dataset
A realistic dataset is installed on first activation and can be reinstalled or removed from the configuration page. All rows are tagged with import_key = 'DCHDEMO'; removal deletes only those rows plus the native third parties and products the generator created, cascading first to any user-created child of a demo parent so no orphan is left on a dead foreign key.
· 8 cocoa suppliers, 8 beans, 28 raw materials, 30 receptions.
· 12 recipes with 71 composition lines, 4 formulations, 12 native finished products with sale and cost prices.
· 14 machines, 5 production lines, 42 production orders with 453 routing operations.
· 32 tempering records, 32 moulding records, 23 enrobing records, 22 packaging records, 22 lots.
· 77 traceability events, 73 quality controls, 8 non-conformities, 11 laboratory analyses, 10 HACCP points.
· 24 maintenance interventions, 48 energy records, 14 AI insights.
· Realism: measured values are drawn inside their own tolerance band with an explicit ~3% reject rate, so conformity lands near 97%; the first production orders are forced to start today so the headline 'production of the day' KPI is never zero.
11. Support
DoliResources — www.doliresources.com — Copyright © 2026 DoliResources. Licence GPL v3 or later.