from openerp.openupgrade import openupgrade


@openupgrade.migrate()
def migrate(cr, version):
    cr.execute(
        '''update hr_holidays
        set meeting_id=calendar_event.id
        from calendar_event where meeting_id=%s''' % (
            openupgrade.get_legacy_name('crm_meeting_id'),
        )
    )

from openerp.openupgrade import openupgrade


@openupgrade.migrate()
def migrate(cr, version):
    cr.execute(
        "ALTER TABLE hr_holidays DROP CONSTRAINT hr_holidays_meeting_id_fkey"
    )
    cr.execute(
        '''update hr_holidays
        set meeting_id=calendar_event.id
        from calendar_event where meeting_id=%s''' % (
            openupgrade.get_legacy_name('crm_meeting_id'),
        )
    )

Remove hr_holidays_meeting_id_fkey constrain to avoid migration issues.
Remove hr_holidays_meeting_id_fkey constrain to avoid migration issues.

- The constraint will be reset by the ORM later.

- Not doing it may both slow the migration and abort it altogether.

  from openerp.openupgrade import openupgrade
  
  
  @openupgrade.migrate()
  def migrate(cr, version):
+     cr.execute(
+         "ALTER TABLE hr_holidays DROP CONSTRAINT hr_holidays_meeting_id_fkey"
+     )
      cr.execute(
          '''update hr_holidays
          set meeting_id=calendar_event.id
          from calendar_event where meeting_id=%s''' % (
              openupgrade.get_legacy_name('crm_meeting_id'),
          )
      )
  
Remove hr_holidays_meeting_id_fkey constrain to avoid migration issues.
## Code Before:
from openerp.openupgrade import openupgrade


@openupgrade.migrate()
def migrate(cr, version):
    cr.execute(
        '''update hr_holidays
        set meeting_id=calendar_event.id
        from calendar_event where meeting_id=%s''' % (
            openupgrade.get_legacy_name('crm_meeting_id'),
        )
    )

## Instruction:
Remove hr_holidays_meeting_id_fkey constrain to avoid migration issues.
## Code After:
from openerp.openupgrade import openupgrade


@openupgrade.migrate()
def migrate(cr, version):
    cr.execute(
        "ALTER TABLE hr_holidays DROP CONSTRAINT hr_holidays_meeting_id_fkey"
    )
    cr.execute(
        '''update hr_holidays
        set meeting_id=calendar_event.id
        from calendar_event where meeting_id=%s''' % (
            openupgrade.get_legacy_name('crm_meeting_id'),
        )
    )
