49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
"""
|
|
Pre-migration for laundry_management 19.0.12.0.0
|
|
|
|
Changes handled:
|
|
1. Commission states: 'paid' only → now 'pending', 'confirmed', 'paid'
|
|
Existing 'paid' rows remain 'paid'. Existing 'pending' rows remain 'pending'.
|
|
'confirmed' is a new state — no existing rows use it, so no data migration needed.
|
|
|
|
2. New model: laundry.payment.wizard — just a new table, nothing to clean.
|
|
|
|
3. New groups: group_laundry_operator, group_laundry_cashier added to hierarchy.
|
|
Existing users with group_laundry_user keep all their permissions (implied).
|
|
|
|
4. Access control: new CSV entries for payment wizard and new groups.
|
|
Handled automatically by Odoo on upgrade.
|
|
|
|
No destructive operations needed in this migration.
|
|
The pre_migrate script from 19.0.11.0.0 already cleaned the legacy tables.
|
|
"""
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def migrate(cr, version):
|
|
if not version:
|
|
return # Fresh install
|
|
|
|
_logger.info('pre_migrate laundry_management 19.0.12.0.0: checking commission states')
|
|
|
|
# Ensure commission state column allows new 'confirmed' value.
|
|
# In Odoo, Selection fields are stored as VARCHAR — no schema change needed.
|
|
# Just verify the column exists and log the existing state distribution.
|
|
cr.execute("""
|
|
SELECT state, COUNT(*) FROM laundry_commission
|
|
GROUP BY state
|
|
ORDER BY state
|
|
""")
|
|
rows = cr.fetchall()
|
|
if rows:
|
|
_logger.info(
|
|
'pre_migrate: commission state distribution: %s',
|
|
{state: count for state, count in rows}
|
|
)
|
|
else:
|
|
_logger.info('pre_migrate: laundry_commission table is empty — fresh data')
|
|
|
|
_logger.info('pre_migrate laundry_management 19.0.12.0.0: complete')
|