Files
Odoo-Modules/fusion_plating/fusion_plating_jobs/scripts/seed_part_coatings.py
gsinghpal 8c76a16366 chore(plating): de-dash shipped code + intake-neutral customer emails
Replace em-dashes and en-dashes with hyphens across 789 shipped source
files (py/xml/js/scss) so the delivered module reads as human-written;
em-dashes had become a recognizable AI-generated tell. Internal .md dev
notes are excluded. The WO-sticker mojibake strippers keep their dash
search targets (now written — / –). No logic changes: comments
and display strings only; validated with py_compile + lxml parse.

Rewrite the 7 customer notification emails to be intake-neutral
(ship-in / drop-off / pickup) and repair-aware, and fix the Shipped
email documents line (packing slip vs bill of lading; certificate only
when issued). Subjects use a hyphen separator.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 00:16:19 -04:00

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`.')