Beispiel #1
0
def map_notify_email(cr):
    openupgrade.map_values(
        cr,
        openupgrade.get_legacy_name('notification_email_send'),
        'notify_email',
        [('all', 'always'), ('comment', 'always'),
         ('email', 'always'), ('none', 'none')],
        table='res_partner', write='sql')
def migrate(cr, version):
    pool = RegistryManager.get(cr.dbname)

    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('priority'),
                           'priority', [('5', '0'), ('4', '0'), ('3', '1'),
                                        ('2', '2'), ('1', '2')],
                           table='project_issue',
                           write='sql')

    openupgrade_80.set_message_last_post(cr, uid, pool, ['project.issue'])

    openupgrade.load_data(cr, 'project_issue',
                          'migrations/8.0.1.0/noupdate_changes.xml')
def migrate(cr, version):
    registry = RegistryManager.get(cr.dbname)

    openupgrade.map_values(
        cr, 'priority', openupgrade.get_legacy_name('priority'),
        [('5', '0'), ('4', '1'), ('3', '2'), ('2', '3'), ('1', '4')],
        table='crm_lead')
    openupgrade.map_values(
        cr, 'priority', openupgrade.get_legacy_name('priority'),
        [('5', '0'), ('4', '0'), ('3', '1'), ('1', '2')],
        table='crm_phonecall')
    openupgrade.logged_query(
        cr, "UPDATE crm_phonecall SET state = %s WHERE state = %s",
        ('draft', 'pending'))

    # Set the date of the last update
    subtype_ids = (
        registry['ir.model.data'].get_object_reference(
            cr, SUPERUSER_ID, 'crm', 'mt_lead_stage')[1],
        registry['ir.model.data'].get_object_reference(
            cr, SUPERUSER_ID, 'crm', 'mt_salesteam_lead_stage')[1])

    # Update event tracking datetime fields
    openupgrade_80.set_message_last_post(
        cr, SUPERUSER_ID, registry, ['crm.phonecall', 'crm.lead'])
    openupgrade.logged_query(
        cr,
        """
        UPDATE crm_lead l
        SET date_last_stage_update = COALESCE(
            (SELECT MAX(create_date) FROM mail_message m
             WHERE subtype_id in %s
                AND m.res_id = l.id),
            l.create_date)
        """, (subtype_ids,))

    # Move opportunity and phonecall to matching calendar_event
    openupgrade.logged_query(
        cr,
        """
        UPDATE calendar_event e
        SET opportunity_id = m.opportunity_id,
            phonecall_id = m.phonecall_id
        FROM crm_meeting m
        WHERE e.{} = m.id""".format(
            openupgrade.get_legacy_name('crm_meeting_id')))

    openupgrade.load_data(cr, 'crm', 'migrations/8.0.1.0/noupdate_changes.xml')
Beispiel #4
0
def migrate(cr, version):
    registry = RegistryManager.get(cr.dbname)

    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('priority'),
                           'priority', [('4', '0'), ('3', '0'), ('2', '1'),
                                        ('1', '2'), ('0', '2')],
                           table='project_task',
                           write='sql')

    openupgrade_80.update_aliases(cr,
                                  registry,
                                  'project.project',
                                  set_parent_thread_id=True,
                                  defaults_id_key='project_id')

    openupgrade_80.set_message_last_post(cr, uid, registry,
                                         ['project.project', 'project.task'])

    openupgrade.load_data(cr, 'project',
                          'migrations/8.0.1.1/noupdate_changes.xml')