chnages
This commit is contained in:
@@ -32,6 +32,18 @@ def post_init_hook(env):
|
||||
_migrate_legacy_uom_columns(env)
|
||||
|
||||
|
||||
def _resolve_kind_id(env, code):
|
||||
"""Look up an fp.step.kind id by code. Returns False if not found.
|
||||
Cheap helper used during seeding so legacy code paths that referenced
|
||||
string codes can keep their semantics."""
|
||||
if not code:
|
||||
return False
|
||||
rec = env['fp.step.kind'].search(
|
||||
[('code', '=', code)], limit=1,
|
||||
)
|
||||
return rec.id or False
|
||||
|
||||
|
||||
def _backfill_contract_review_template(env):
|
||||
"""Idempotent — ensure the Contract Review library template exists.
|
||||
|
||||
@@ -45,7 +57,7 @@ def _backfill_contract_review_template(env):
|
||||
return # already there
|
||||
tpl = Tpl.create({
|
||||
'name': 'Contract Review',
|
||||
'default_kind': 'contract_review',
|
||||
'kind_id': _resolve_kind_id(env, 'contract_review'),
|
||||
})
|
||||
tpl.action_seed_default_inputs()
|
||||
_logger.info(
|
||||
@@ -236,7 +248,7 @@ def _create_template_from_node(env, node, seen):
|
||||
'process_type_id': node.process_type_id.id,
|
||||
'requires_signoff': node.requires_signoff,
|
||||
'requires_predecessor_done': node.requires_predecessor_done,
|
||||
'default_kind': kind,
|
||||
'kind_id': _resolve_kind_id(env, kind),
|
||||
}
|
||||
# Snapshot tank_ids if the node has them (added by Sub 12a;
|
||||
# existing nodes may not).
|
||||
@@ -275,7 +287,10 @@ def _seed_minimal_library(env):
|
||||
('Shipping', 'ship'),
|
||||
]
|
||||
for name, kind in minimal:
|
||||
tpl = Tpl.create({'name': name, 'default_kind': kind})
|
||||
tpl = Tpl.create({
|
||||
'name': name,
|
||||
'kind_id': _resolve_kind_id(env, kind),
|
||||
})
|
||||
tpl.action_seed_default_inputs()
|
||||
_logger.info(
|
||||
'Fusion Plating: seeded minimal step library (%s entries)',
|
||||
|
||||
Reference in New Issue
Block a user