Two follow-up seed scripts after the main demo reset: 1. seed_work_centres.py: creates one fp.work.centre per existing fusion.plating.work.center (matched by code), classifying kind from name/code keywords. Then backfills work_centre_id on every fp.job.step whose recipe_node has a legacy work_center_id with a matching native code. Plant Overview kanban now has columns instead of one big 'Unassigned' bucket. 2. seed_part_coatings.py: assigns existing fp.coating.config rows (with recipes) to up to 20 bare fp.part.catalog rows round-robin. Field on the part is x_fc_default_coating_config_id. Future SO confirms via these parts will naturally generate full recipe-linked steps via _generate_steps_from_recipe. Both idempotent — re-running creates nothing new. Run on entech: 9 native work centres created, all 234 existing fp.job.step rows bound. Parts with coating: 2 -> 22 (28 -> 8 bare). Part of: native job model migration (spec 2026-04-25) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
#
|
|
# Assigns existing fp.coating.config rows (with recipes) to parts that
|
|
# don't have one yet. Round-robin distribution. Idempotent.
|
|
#
|
|
# Field name on fp.part.catalog is x_fc_default_coating_config_id.
|
|
|
|
COATING_FIELD = 'x_fc_default_coating_config_id'
|
|
|
|
|
|
def run(env):
|
|
print('=== Assigning coatings to bare parts ===')
|
|
|
|
Part = env['fp.part.catalog']
|
|
Coating = env['fp.coating.config']
|
|
|
|
coatings_with_recipe = Coating.search([('recipe_id', '!=', False)])
|
|
if not coatings_with_recipe:
|
|
print(' No coatings with recipes available — abort')
|
|
return
|
|
print(f' Coatings with recipes: {len(coatings_with_recipe)}')
|
|
|
|
bare_parts = Part.search([(COATING_FIELD, '=', False)])
|
|
print(f' Parts without coating: {len(bare_parts)}')
|
|
|
|
# Assign first 20 bare parts (or all if fewer)
|
|
to_assign = bare_parts[:20]
|
|
n = 0
|
|
for i, part in enumerate(to_assign):
|
|
coating = coatings_with_recipe[i % len(coatings_with_recipe)]
|
|
part[COATING_FIELD] = coating.id
|
|
n += 1
|
|
print(f' {part.name!r} -> {coating.name!r}')
|
|
|
|
env.cr.commit()
|
|
print()
|
|
print(f'=== Done. Assigned coatings to {n} parts ===')
|
|
final_count = Part.search_count([(COATING_FIELD, '!=', False)])
|
|
print(f' Parts with coating now: {final_count}')
|
|
|
|
|
|
try:
|
|
run(env)
|
|
except NameError:
|
|
print('Run inside `odoo shell`.')
|