Configuration¶
System parameters (ir.config_parameter)¶
| Key | Default | Description |
|---|---|---|
roots_hemms_mass_import.row_cap | 5000 | Maximum data rows per XLSX file. Files over the cap raise a clear error before any record is parsed. Increase only if you've benchmarked transaction-timeout headroom on your deployment. |
roots_hemms_mass_import.preview_ttl_hours | 1 | Lifetime of the dry-run preview cache (data_json blob on hemms.import.batch). Stale batches in previewed state past this age are reset to draft and their cache cleared by the hourly GC cron. The original file_data attachment is kept, letting the user re-trigger. |
Edit via Settings → Technical → System Parameters or self.env['ir.config_parameter'].sudo().set_param(key, value).
Scheduled action¶
| Name | Interval | Method |
|---|---|---|
HEMMS Mass-Import: GC stale preview batches | 1 hour | model._gc_previewed_batches() |
Resets any hemms.import.batch whose state == "previewed" AND write_date < (now - preview_ttl_hours) back to draft and clears its data_json.
Security groups¶
| Group | Reads batches | Writes / commits / deletes |
|---|---|---|
base.group_user | Only batches they created or committed | None (read-only) |
maintenance.group_equipment_manager | All batches | Full CRUD + force-delete past D7 guards |
The record rule on hemms.import.batch (defined in security/mass_import_security.xml) scopes non-managers to their own batches. Equipment managers see and can act on every batch.
Delete window¶
Hard-coded in models/hemms_import_batch.py:
A committed batch may be deleted by an equipment manager any time; non-managers can only delete within this window AND only if no downstream maintenance.request or hemms.service.contract (Q3) references the tagged records. See Workflows → Deleting a batch.
To change the window, edit the module constant and upgrade — adjusting at runtime requires a code change because the value is checked at every delete call.
MoPH 82-class match¶
The mass-import validator uses strict exact matching against the Q5 device-class seed:
- Tries
name_enfirst (case-sensitive, NFC-normalised, whitespace-stripped) - Falls back to
name_th(case doesn't apply to Thai) - Anything else FAILs the row
This is intentional — fuzzy / Levenshtein matching invites silent miscategorisation, which corrupts the HA annual report. To extend the catalogue, add rows to the hemms.ha.device.class table via the MoPH Device Classes (HA) menu (or seed XML on a per-deployment basis).
Module dependencies¶
| Module | Why |
|---|---|
mail | Chatter on batches (audit trail) |
hr | hr.department is the location target model |
roots_hemms_pm (Q1) | PM event lookup for the delete guard |
roots_hemms_asset_master | ref_uniq SQL constraint on maintenance.equipment.ref (equipment business key) |
roots_hemms_ha_report (Q5) | MoPH 82-class seed for strict matching; roots_ha_risk_tier field on equipment |
Fields the import populates¶
Equipment¶
| Field | Source column | Required |
|---|---|---|
ref | Equipment Ref. No. | yes (business key) |
name | Equipment Name | yes |
serial_no | Serial Number | no |
model | Model | no |
partner_id | Vendor (matched by name) | no |
department_id | Department (matched by complete_name) | no |
device_class_id | MoPH Device Class (EN or TH, strict match) | no |
roots_ha_risk_tier | Risk Tier (override: high / medium / low) | no |
current_condition | Condition (in_use / broken / deteriorated / lost / unused) | no |
Vendor (res.partner)¶
| Field | Source column | Required |
|---|---|---|
name | Vendor Name | yes (business key Layer C) |
vat | Tax ID (VAT) | no (business key Layer A) |
country_id | Country Code (ISO 2-letter) | no (business key Layer B with name) |
email, phone, street, city | direct copy | no |
Location (hr.department)¶
| Field | Source column | Required |
|---|---|---|
name | Department Name | yes |
parent_id | Parent Department (matched by complete_name) | no |