Includes: - Odoo 19 framework (odoo/) - 27 custom EnCoach addons (new_project/custom_addons/) - encoach_core, encoach_api, encoach_lms_api, encoach_adaptive_api - encoach_exam, encoach_taxonomy, encoach_adaptive, encoach_assignment - encoach_ai, encoach_ai_grading, encoach_ai_generation, encoach_ai_media - encoach_courseware, encoach_communication, encoach_subscription - encoach_notification, encoach_approval, encoach_branding - encoach_classroom, encoach_registration, encoach_stats - encoach_faq, encoach_ticket, encoach_training, encoach_resources - encoach_adaptive_ai, encoach_sis - 21 OpenEduCat Enterprise modules (new_project/enterprise-19/) - 14 OpenEduCat Community modules (new_project/openeducat_erp-19.0/) - Configuration: odoo.conf, requirements.txt, scripts - 200+ REST API endpoints with JWT authentication - SRS and test documentation Made-with: Cursor
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from odoo.tools import sql
|
|
|
|
|
|
def migrate(cr, version):
|
|
# Select relevant ids to generate the list of x_plan_id column names, removing the id of the project plan
|
|
cr.execute(
|
|
"""
|
|
SELECT value::int
|
|
FROM ir_config_parameter
|
|
WHERE key = 'analytic.project_plan'
|
|
"""
|
|
)
|
|
[project_plan_id] = cr.fetchone()
|
|
cr.execute("SELECT id FROM account_analytic_plan WHERE id != %s AND parent_id IS NULL", [project_plan_id])
|
|
plan_ids = [r[0] for r in cr.fetchall()]
|
|
column_names = [f"x_plan{id_}_id" for id_ in plan_ids]
|
|
# Update on_delete for existing x_plan_id columns
|
|
cr.execute(
|
|
"""
|
|
UPDATE ir_model_fields
|
|
SET on_delete = 'restrict'
|
|
WHERE model = 'account.analytic.line'
|
|
AND on_delete = 'set null'
|
|
AND name = ANY(%s)
|
|
""",
|
|
[column_names],
|
|
)
|
|
# Change the constraint on the table definition
|
|
for column in column_names:
|
|
sql.drop_constraint(cr, 'account_analytic_line', f'account_analytic_line_{column}_fkey')
|
|
sql.add_foreign_key(cr, 'account_analytic_line', column, 'account_analytic_account', 'id', 'restrict')
|