Example #1
0
def map_account_tax_template_type(cr):
    """Same comments as in map_account_tax_type"""
    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('type'),
                           'type', [('code', 'group')],
                           table='account_tax_template',
                           write='sql')
Example #2
0
def res_lang_week_start_map_values(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name("week_start"),
        "week_start",
        [(1, "1"), (2, "2"), (3, "3"), (4, "4"), (5, "5"), (6, "6"), (7, "7")],
        table="res_lang",
    )
Example #3
0
def map_project_project_rating_status(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name("rating_status"),
        "rating_status",
        [("no", "stage")],
        table="project_project",
    )
Example #4
0
def deactivate_closed_accounts(cr):
    # not using sql to restore account_type but map values
    openupgrade.map_values(
        cr, openupgrade.get_legacy_name('account_type'),
        'active',  [('closed',  False), ('normal', True)],
        table='account_analytic_account',
        write='sql'
    )
Example #5
0
def map_stock_rule_action(cr):
    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('action'),
                           'action', [
                               ('move', 'pull'),
                           ],
                           table='stock_rule',
                           write='sql')
Example #6
0
def map_intrastat_product_declaration_month(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name("month"),
        "month",
        _months,
        table="intrastat_product_declaration",
    )
def map_account_journal_post_at_bank_rec(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('post_at_bank_rec'),
        'post_at',
        [(True, 'bank_rec')],
        table='account_journal',
    )
def map_res_company_fiscalyear_last_month(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('fiscalyear_last_month'),
        'fiscalyear_last_month',
        [(x, '%s' % x) for x in range(1, 13, 1)],
        table='res_company',
    )
Example #9
0
def map_calendar_event_byday(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name("byday"),
        "byday",
        [("5", "-1")],
        table="calendar_event",
    )
Example #10
0
def map_account_journal_bank_statements_source(cr):
    openupgrade.map_values(
        cr,
        openupgrade.get_legacy_name('bank_statements_source'),
        'bank_statements_source',
        [('manual', 'undefined'),
         ],
        table='account_journal', write='sql')
Example #11
0
def migrate(env, version):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('timesheet_range'),
        'timesheet_range',
        [('day', 'month')],
        table='res_company',
    )
def update_receiptbook_type(env):
    cr = env.cr
    openupgrade.map_values(
        cr,
        'type', 'partner_type',
        # openupgrade.get_legacy_name('type'), 'partner_type',
        [('receipt', 'customer'), ('payment', 'supplier')],
        table='account_payment_receiptbook', write='sql')
Example #13
0
def res_company_sheet_range_map_values(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name("sheet_range"),
        "sheet_range",
        [(MONTHLY, "MONTHLY"), (WEEKLY, "WEEKLY"), (DAILY, "DAILY")],
        table="res_company",
    )
Example #14
0
def set_company_loc_ar(cr):
    _logger.info('Setting loc ar on companies')
    openupgrade.map_values(
        cr,
        # openupgrade.get_legacy_name('type_tax_use'), 'localization',
        'use_argentinian_localization', 'localization',
        # [('all', 'none')],
        [(True, 'argentina')],
        table='res_company', write='sql')
Example #15
0
def map_track_service(env):
    """"Map values for old `track_service` field (copied in sale pre-migration)
    according this mapping:

    track_service           service_tracking
    -------------           ----------------
    'manual'		         'no'
    'task'                  if not project_id: 'task_new_project'
                            if project_id: 'task_global_project'
    'timesheet'             'project_only'

    Project field depends on company, so this is applicable as soon as one
    company has any project set.
    """
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('track_service'),
        'service_tracking', [
            ('manual', 'no'),
            ('timesheet', 'project_only'),
        ], table='product_template',
    )
    # Need to be done through subquery as unique option for proper joining
    openupgrade.logged_query(
        env.cr, """
        UPDATE product_template pt
        SET service_tracking = 'task_new_project'
        FROM (
            SELECT pt.id FROM
            product_template pt
            JOIN ir_model_fields imf ON imf.name = 'project_id'
                AND imf.model = 'product.template'
            LEFT JOIN ir_property ip ON ip.fields_id = imf.id
                AND ip.res_id = 'product.template,' || pt.id::text
            WHERE pt.%s = 'task'
                AND ip.value_reference IS NULL
        ) sub
        WHERE sub.id = pt.id""",
        (AsIs(openupgrade.get_legacy_name('track_service')), ),
    )
    openupgrade.logged_query(
        env.cr, """
        UPDATE product_template pt
        SET service_tracking = 'task_global_project'
        FROM (
            SELECT pt.id FROM
            product_template pt
            JOIN ir_model_fields imf ON imf.name = 'project_id'
                AND imf.model = 'product.template'
            LEFT JOIN ir_property ip ON ip.fields_id = imf.id
                AND ip.res_id = 'product.template,' || pt.id::text
            WHERE pt.%s = 'task'
                AND ip.value_reference IS NOT NULL
        ) sub
        WHERE sub.id = pt.id""",
        (AsIs(openupgrade.get_legacy_name('track_service')), ),
    )
def migrate(env, version):
    openupgrade.copy_columns(env.cr, _column_copies)
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('type'),
        'type',
        [('datetime', 'date')],
        table='survey_question',
    )
Example #17
0
def map_payment_transaction_state(cr):
    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('state'),
                           'state', [
                               ('refunding', 'cancel'),
                               ('refunded', 'cancel'),
                           ],
                           table='payment_transaction',
                           write='sql')
Example #18
0
def migrate(env, version):
    openupgrade.copy_columns(env.cr, _column_copies)
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('measure_type'),
        'measure_type',
        [('time', 'working_time')],
        table='uom_category',
    )
def map_stock_location_usage(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('usage'),
        'usage',
        [('procurement', 'transit'),
         ],
        table='stock_location',
    )
Example #20
0
def set_company_loc_ar(env):
    cr = env.cr
    openupgrade.map_values(
        cr,
        # openupgrade.get_legacy_name('type_tax_use'), 'localization',
        'use_argentinian_localization', 'localization',
        # [('all', 'none')],
        [(True, 'argentina')],
        table='res_company', write='sql')
Example #21
0
def map_snailmail_letter_state(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('state'),
        'state',
        [('draft', 'pending'),
         ],
        table='snailmail_letter',
    )
Example #22
0
def map_account_tax_type(cr):
    """ The tax type 'code' is not an option in the account module for v9.
    We need to assign a temporary 'dummy' value until module
    account_tax_python is installed. In post-migration we will
    restore the original value."""
    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('type'),
                           'type', [('code', 'group')],
                           table='account_tax',
                           write='sql')
def map_journal_state(cr):
    openupgrade.map_values(
        cr,
        openupgrade.get_legacy_name('type'), 'type',
        [
            ('purchase_refund', 'purchase'),
            ('sale_refund', 'sale'),
            ('situation', 'general'),
        ],
        table='account_journal', write='sql')
def migrate(env, version):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('category'),
        'category',
        [('both', 'contract')],
        table='fleet_service_type',
    )
    # Update state of all the contracts
    env['fleet.vehicle.log.contract'].scheduler_manage_contract_expiration()
Example #25
0
def map_product_template_type(cr):
    """ The product template type value 'stockable' is not an option in the
    product module for v9. We need to assign a temporary 'dummy' value
    until module stock is installed. In post-migration we will
    restore the original value."""
    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('type'),
                           'type', [('product', 'consu')],
                           table='product_template',
                           write='sql')
Example #26
0
def map_mail_notification_type(env):
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name('service_tracking'),
        'service_tracking',
        [
            ('task_new_project', 'task_in_project'),
        ],
        table='product_template',
    )
Example #27
0
def migrate(cr, version):
    openupgrade.rename_columns(cr, _column_renames)
    cr.execute(
        # we rely on the ORM to write this value
        'alter table ir_model_fields add column store boolean')
    openupgrade.copy_columns(cr, {
        'ir_act_window': [
            ('target', None, None),
        ],
    })
    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('target'),
                           'target', [
                               ('inlineview', 'inline'),
                           ],
                           table='ir_act_window')
    cr.execute(
        "update ir_ui_view set type='kanban' where type='sales_team_dashboard'"
    )
    cr.execute('update res_currency set symbol=name where symbol is null')
    # create xmlids for installed languages
    cr.execute('''insert into ir_model_data
        (module, name, model, res_id)
        select
        'base',
        'lang_' ||
        case
            when char_length(code) > 2 then
            case
                when upper(substring(code from 1 for 2)) =
                upper(substring(code from 4 for 2)) then
                    substring(code from 1 for 2)
                else
                    code
            end
            else
                code
        end,
        'res.lang', id
        from res_lang''')
    openupgrade.update_module_names(
        cr,
        [
            ('account_full_reconcile', 'account'),
            ('project_timesheet', 'hr_timesheet'),
            ('share', 'base'),
            ('web_tip', 'web'),
            ('web_view_editor', 'web'),
            ('mail_tip', 'mail'),
            ('im_odoo_support', 'im_livechat'),
            # OCA/sale-workflow
            ('sale_order_back2draft', 'sale'),
        ],
        merge_modules=True,
    )
Example #28
0
def migrate(cr, version):
    openupgrade.load_data(cr, 'hr_recruitment',
                          'migrations/9.0.1.0/noupdate_changes.xml')
    openupgrade.map_values(cr,
                           openupgrade.get_legacy_name('priority'),
                           'priority', [('1', '0'), ('2', '0'), ('3', '1'),
                                        ('4', '3')],
                           table='hr_applicant',
                           write='sql')
    update_applicant_availability(cr)
    migrate_applicant_source(cr)
Example #29
0
def migrate(cr, version):
    pool = pooler.get_pool(cr.dbname)
    uid = SUPERUSER_ID
    openupgrade_80.set_message_last_post(cr, uid, pool, ['crm.claim'])
    openupgrade.map_values(cr,
                           'priority',
                           openupgrade.get_legacy_name('priority'),
                           [('1', '2'), ('3', '1'), ('4', '0'), ('5', '0')],
                           table='crm_claim')
    openupgrade.load_data(cr, 'crm_claim',
                          'migrations/8.0.1.0/noupdate_changes.xml')
Example #30
0
def map_training_participant(env):
    openupgrade.map_values(
        env.cr,
        "state",
        "state",
        [
            ("absence", "draft"),
        ],
        table="hr_training_partisipant",
        write="sql",
    )