# -*- coding: utf-8 -*- """Post-migration for 19.0.2.1.0 - align rate-card + categories to Westin's printed service-rate card. Sites that installed any earlier Bundle 9 build have: - Old callout.rate rows with $120/$95/0.85 values (B9 placeholder rates) - Stairlift / porch_lift categories with equipment_class='standard' Both have noupdate=1 in their seed XML so a normal -u upgrade won't fix them. This script: 1. Wipes the four B9-only rate xml_ids and re-imports the seed 2. Updates lift / porch / lift_chair categories to equipment_class='lift_elevating' After this runs once, future upgrades respect noupdate=1 normally (admin tweaks are preserved). """ from odoo.tools.sql import column_exists def migrate(cr, version): if not version: return # fresh install - seed loads correctly cr.execute(""" UPDATE fusion_repair_product_category SET equipment_class = 'lift_elevating' WHERE code IN ('stairlift', 'porch_lift', 'lift_chair') AND (equipment_class IS NULL OR equipment_class = 'standard'); """) # Wipe the four B9 rate rows so the new noupdate=1 seed re-creates them # with the printed values. Only deletes rows that were originally seeded # by this module (xml_id present) - admin-created rate rows stay put. cr.execute(""" DELETE FROM fusion_repair_callout_rate WHERE id IN ( SELECT res_id FROM ir_model_data WHERE module = 'fusion_repairs' AND model = 'fusion.repair.callout.rate' AND name IN ('callout_rate_regular', 'callout_rate_after_hours', 'callout_rate_weekend', 'callout_rate_holiday') ); DELETE FROM ir_model_data WHERE module = 'fusion_repairs' AND model = 'fusion.repair.callout.rate' AND name IN ('callout_rate_regular', 'callout_rate_after_hours', 'callout_rate_weekend', 'callout_rate_holiday'); """)