57 lines
2.2 KiB
Python
57 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
# Part of the Fusion Plating product family.
|
|
|
|
"""19.0.12.1.0 — Convert every free-text UoM column to the curated
|
|
selection keys defined in models/_fp_uom_selection.py.
|
|
|
|
Runs after fusion_plating's tables have been re-described (so the
|
|
columns are now Selection-typed at the ORM level), but before users
|
|
hit the new views. Idempotent — re-running maps already-converted
|
|
values to themselves and leaves them in place.
|
|
"""
|
|
|
|
import logging
|
|
|
|
from odoo.api import Environment
|
|
|
|
from odoo.addons.fusion_plating.models._fp_uom_selection import (
|
|
fp_migrate_uom_column,
|
|
)
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def migrate(cr, version):
|
|
env = Environment(cr, 1, {}) # SUPERUSER
|
|
|
|
targets = [
|
|
# core
|
|
('fusion_plating_bath_parameter', 'uom', 'bath parameter'),
|
|
('fusion_plating_process_node_input', 'uom', 'process node input'),
|
|
('fusion_plating_process_node_input', 'target_unit', 'process node target'),
|
|
('fp_step_template_input', 'target_unit', 'step template input target'),
|
|
# compliance (only migrated when the module is installed — the
|
|
# helper is no-op when the table doesn't exist)
|
|
('fusion_plating_discharge_limit', 'uom', 'discharge limit'),
|
|
('fusion_plating_discharge_sample_line', 'uom', 'discharge sample line'),
|
|
('fusion_plating_waste_manifest', 'uom', 'waste manifest'),
|
|
('fusion_plating_waste_stream', 'generation_uom', 'waste stream'),
|
|
('fusion_plating_spill_register', 'uom', 'spill register'),
|
|
# safety
|
|
('fusion_plating_chemical', 'container_uom', 'chemical container'),
|
|
('fusion_plating_exposure_monitoring', 'uom', 'exposure monitoring'),
|
|
]
|
|
total_rewritten = total_cleared = 0
|
|
for table, column, label in targets:
|
|
rewritten, cleared = fp_migrate_uom_column(env, table, column, label)
|
|
total_rewritten += rewritten
|
|
total_cleared += cleared
|
|
|
|
_logger.info(
|
|
'Fusion Plating 19.0.12.1.0 — UoM migration complete: '
|
|
'%s rewritten, %s cleared (across %s columns).',
|
|
total_rewritten, total_cleared, len(targets),
|
|
)
|