Pre-deploy fixes for Phase 1 permissions overhaul branch (catches by
final-reviewer subagent + main session).
CRITICAL FIXES:
C1: groups_id -> group_ids (Odoo 19 field rename). Affected ~30 sites
across 4 model files, 1 view, 7 test files. Documented project
gotcha (feedback_odoo19_groups_id_renamed.md) that the implementer
subagents missed because they don't see user memory.
C2: action_fp_resolve_plating_landing server action now calls
env['ir.actions.act_window'].sudo()._fp_resolve_landing_for_current_user()
instead of the old inline priority chain. Phase E's role-based
dispatch was previously dead code.
C3: New migrations/19.0.21.1.0/post-migrate.py triggers
_fp_post_init_role_migration(env) on -u. post_init_hook only fires
on INSTALL in Odoo 19, not UPGRADE -- so Phase H's preview creation
wouldn't have auto-fired on entech without this script. Module
version bumped to 19.0.21.1.0 to match the migration directory.
C4: Team kanban template rewritten for Odoo 19 (<t t-name='card'> with
semantic <aside>/<main>) instead of legacy <t t-name='kanban-box'>.
Previous template threw 'Missing card template' at render.
IMPORTANT FIXES:
I1: SO state=sent Confirm button (id='action_confirm') now also gated
to group_fp_sales_manager. Previously only the state=draft button
was gated; Sales Reps could send-and-confirm via the secondary path.
I2: Designated Officials picker domain uses all_group_ids (transitive)
instead of group_ids (explicit only). Owner users now correctly
appear as eligible CGP DO candidates via the implied_ids chain.
I3: test_menu_visibility.py compliance hub xmlid corrected to
fusion_plating.menu_fp_compliance_hub (was
fusion_plating_compliance.menu_fp_compliance_hub which doesn't exist
-- the hub menu is defined in core's fp_menu.xml). Tests were
silently skipTest-ing.
I4: _inverse_plating_role chatter audit reads old role from DB via SQL
(bypasses cache) so 'old -> new' displays actual values, and
short-circuits no-op writes.
I5: _FP_ROLE_MAPPING_RULES reordered: cgp_designated_official fires
BEFORE admin/uid_1_or_2 so admin+DO users keep the capability_delta
marker that triggers res.company.x_fc_cgp_designated_official_id
auto-set during migration.
I6: _cron_purge_expired_migrations skips groups with active users
instead of unlink-ing unconditionally. Defense against rollback
safety being bypassed by manual role assignments post-migration.
CLAUDE.md updated with 3 new durable rules (13b kanban card template,
13c group_ids vs all_group_ids, 13d post_init_hook only on install).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
92 lines
4.0 KiB
Python
92 lines
4.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Single source of truth for migration mapping rules + old-group xmlids.
|
|
|
|
The mapping predicates are evaluated against res.users records. First match
|
|
wins (highest-precedence first). See spec Section 5 + plan Phase H.
|
|
"""
|
|
|
|
# Every plating role group xmlid that exists BEFORE the migration (deprecated
|
|
# but still defined for backward-compat during 30-day rollback window).
|
|
_FP_OLD_GROUP_XMLIDS = (
|
|
'fusion_plating.group_fusion_plating_operator',
|
|
'fusion_plating.group_fusion_plating_supervisor',
|
|
'fusion_plating.group_fusion_plating_manager',
|
|
'fusion_plating.group_fusion_plating_admin',
|
|
'fusion_plating_configurator.group_fp_estimator',
|
|
'fusion_plating_configurator.group_fp_shop_manager',
|
|
'fusion_plating_invoicing.group_fp_accounting',
|
|
'fusion_plating_receiving.group_fp_receiving',
|
|
'fusion_plating_cgp.group_fusion_plating_cgp_officer',
|
|
'fusion_plating_cgp.group_fusion_plating_cgp_designated_official',
|
|
'fusion_plating_jobs.group_fusion_plating_legacy_menus',
|
|
)
|
|
|
|
# New role -> the group xmlid to add when migration assigns this role.
|
|
# 'no' maps to None (no plating group added; old ones still get removed).
|
|
_NEW_ROLE_XMLID = {
|
|
'no': None,
|
|
'technician': 'fusion_plating.group_fp_technician',
|
|
'sales_rep': 'fusion_plating.group_fp_sales_rep',
|
|
'shop_manager': 'fusion_plating.group_fp_shop_manager_v2',
|
|
'sales_manager': 'fusion_plating.group_fp_sales_manager',
|
|
'manager': 'fusion_plating.group_fp_manager',
|
|
'quality_manager': 'fusion_plating.group_fp_quality_manager',
|
|
'owner': 'fusion_plating.group_fp_owner',
|
|
}
|
|
|
|
# Mapping rules: (label, predicate, new_role, capability_delta_or_None)
|
|
# Highest precedence first; first match wins.
|
|
# Predicate is a callable taking a res.users record; returns bool.
|
|
_FP_ROLE_MAPPING_RULES = [
|
|
# cgp_designated_official MUST be first so admin/uid_1/uid_2 users who ALSO
|
|
# hold the DO group still get the capability_delta marker — which is what
|
|
# triggers action_approve_and_run to set res.company.x_fc_cgp_designated_official_id.
|
|
# If admin matched first, the DO field would never get populated for shops
|
|
# where the admin is also the registered PSPC Designated Official.
|
|
('cgp_designated_official',
|
|
lambda u: u.has_group('fusion_plating_cgp.group_fusion_plating_cgp_designated_official'),
|
|
'owner', 'Was CGP DO; field set on res.company'),
|
|
('uid_1_or_2',
|
|
lambda u: u.id in (1, 2),
|
|
'owner', None),
|
|
('admin',
|
|
lambda u: u.has_group('fusion_plating.group_fusion_plating_admin'),
|
|
'owner', None),
|
|
('cgp_officer',
|
|
lambda u: u.has_group('fusion_plating_cgp.group_fusion_plating_cgp_officer'),
|
|
'quality_manager', None),
|
|
('manager',
|
|
lambda u: u.has_group('fusion_plating.group_fusion_plating_manager'),
|
|
'manager', None),
|
|
('shop_manager_old',
|
|
lambda u: u.has_group('fusion_plating_configurator.group_fp_shop_manager'),
|
|
'manager', None),
|
|
('accounting',
|
|
lambda u: u.has_group('fusion_plating_invoicing.group_fp_accounting'),
|
|
'manager', None),
|
|
('estimator_alone',
|
|
lambda u: (u.has_group('fusion_plating_configurator.group_fp_estimator')
|
|
and not u.has_group('fusion_plating.group_fusion_plating_manager')),
|
|
'sales_rep', 'Loses order-confirm authority'),
|
|
('supervisor',
|
|
lambda u: u.has_group('fusion_plating.group_fusion_plating_supervisor'),
|
|
'shop_manager', None),
|
|
('receiving',
|
|
lambda u: u.has_group('fusion_plating_receiving.group_fp_receiving'),
|
|
'shop_manager', None),
|
|
('operator',
|
|
lambda u: u.has_group('fusion_plating.group_fusion_plating_operator'),
|
|
'technician', None),
|
|
('catchall',
|
|
lambda u: True,
|
|
'no', None),
|
|
]
|
|
|
|
|
|
def fp_resolve_target_role(user):
|
|
"""Returns (role_key, capability_delta_or_None). First predicate match wins."""
|
|
for _label, predicate, role, delta in _FP_ROLE_MAPPING_RULES:
|
|
if predicate(user):
|
|
return role, delta
|
|
return 'no', None
|