Exemple #1
0
def migrate(cr, version):
    if not version:
        return
    legacy_reviewer_id =\
        openupgrade.get_legacy_name("reviewer_id")
    legacy_reviewer_group_id =\
        openupgrade.get_legacy_name("reviewer_group_id")
    with api.Environment.manage():
        env = api.Environment(cr, SUPERUSER_ID, {})
        openupgrade.m2o_to_x2m(
            cr=cr,
            model=env["tier.definition.review"],
            table="tier_definition_review",
            field="reviewer_ids",
            source_field=legacy_reviewer_id,
        )
        openupgrade.m2o_to_x2m(
            cr=cr,
            model=env["tier.definition.review"],
            table="tier_definition_review",
            field="reviewer_group_ids",
            source_field=legacy_reviewer_group_id,
        )
    openupgrade.drop_columns(
        cr=cr,
        column_spec=[
            ("tier_definition_review", legacy_reviewer_id),
            ("tier_definition_review", legacy_reviewer_group_id),
        ],
    )
def convert_many2one_stock_inventory_product_and_location(env):
    openupgrade.m2o_to_x2m(env.cr, env['stock.inventory'], 'stock_inventory',
                           'location_ids',
                           openupgrade.get_legacy_name('location_id'))
    openupgrade.m2o_to_x2m(env.cr, env['stock.inventory'], 'stock_inventory',
                           'product_ids',
                           openupgrade.get_legacy_name('product_id'))
Exemple #3
0
def migrate(env, version):
    compute_stock_move_reference(env)
    compute_picking_scheduled_date(env)
    product_assign_responsible(env)
    create_specific_procurement_rules_from_globals(env)
    set_quant_reserved_qty(env)
    openupgrade.m2o_to_x2m(
        env.cr,
        env['stock.move'],
        'stock_move',
        'move_dest_ids',
        'move_dest_id',
    )
    # TODO: Get is_initial_demand_editable, is_locked values in stock.move
    set_partially_available_state(env)
    create_stock_move_line(env)
    fill_missing_lots_for_sml(env)
    create_stock_move_line_incoming(env)
    create_stock_move_line_reserved(env)
    create_stock_move_line_from_inventory_moves(env)
    fill_config_parameter_use_propagation_minimum_delta(env)
    recompute_stock_move_line_qty_different_uom(env)
    openupgrade.load_data(
        env.cr,
        'stock',
        'migrations/11.0.1.1/noupdate_changes.xml',
    )
def map_list_id_to_list_ids(env):
    """Set the list_ids for the list_id in mail.mass_mailing.contact"""
    openupgrade.m2o_to_x2m(
        env.cr,
        env['mail.mass_mailing.contact'],
        'mail_mass_mailing_contact',
        'list_ids',
        'list_id',
    )
Exemple #5
0
def type_change_payment_transaction_and_sale_order(env):
    if openupgrade.column_exists(env.cr, 'sale.order',
                                 openupgrade.get_legacy_name('payment_tx_id')):
        openupgrade.m2o_to_x2m(env.cr, env['sale.order'], 'sale_order',
                               'transaction_ids',
                               openupgrade.get_legacy_name('payment_tx_id'))
        openupgrade.m2o_to_x2m(env.cr, env['payment.transaction'],
                               'payment_transaction', 'sale_order_ids',
                               openupgrade.get_legacy_name('sale_order_id'))
def migrate(env, version):
    # Convert invoice_line_id Many2one field to Many2many field if relation
    # table is empty.
    # This is due to a commit from v11 done after v12 migration, so is possible
    # that this field is already converted
    sql = "SELECT COUNT(*) FROM  stock_move_invoice_line_rel;" ""
    env.cr.execute(sql)
    if not env.cr.fetchone():
        openupgrade.m2o_to_x2m(env.cr, env['stock.move'], 'stock_move',
                               'invoice_line_ids', 'invoice_line_id')
Exemple #7
0
def migrate(cr, version):
    if not version:
        return
    with api.Environment.manage():
        env = api.Environment(cr, SUPERUSER_ID, {})
        openupgrade.m2o_to_x2m(
            cr, env['stock.move'], 'stock_move', 'invoice_line_ids',
            openupgrade.get_legacy_name('invoice_line_id'))
        openupgrade.m2o_to_x2m(
            cr, env['stock.picking'], 'stock_picking', 'invoice_ids',
            openupgrade.get_legacy_name('invoice_id'))
def migrate(env, version):
    if not version:
        return

    openupgrade.m2o_to_x2m(
        env.cr,
        env['lighting.product'],
        'lighting_product',
        'application_ids',
        openupgrade.get_legacy_name('application_id'),
    )
def migrate(env, version):
    if not version:
        return

    openupgrade.m2o_to_x2m(
        env.cr,
        env['lighting.product'],
        'lighting_product',
        'auxiliary_equipment_ids',
        openupgrade.get_legacy_name('auxiliary_equipment_id'),
    )
Exemple #10
0
def _convert_next_activities(env):
    columns = [
        'activity_1_id',
        'activity_2_id',
        'activity_3_id',
    ]
    for column in columns:
        openupgrade.m2o_to_x2m(
            env.cr, env['crm.activity'], 'crm_activity',
            'recommended_activity_ids', openupgrade.get_legacy_name(column),
        )
Exemple #11
0
def migrate(env, version):
    product_assign_responsible(env)
    create_specific_procurement_rules_from_globals(env)
    set_quant_reserved_qty(env)
    openupgrade.m2o_to_x2m(
        env.cr,
        env['stock.move'],
        'stock_move',
        'move_dest_ids',
        'move_dest_id',
    )
    # TODO: Get is_initial_demand_editable, is_locked values in stock.move
    set_partially_available_state(env)
    create_stock_move_line(env)
def convert_m2o_to_x2m_fields(env):
    openupgrade.m2o_to_x2m(
        env.cr,
        env["stock.inventory"],
        "stock_inventory",
        "location_ids",
        openupgrade.get_legacy_name("location_id"),
    )
    openupgrade.m2o_to_x2m(
        env.cr,
        env["stock.inventory"],
        "stock_inventory",
        "product_ids",
        openupgrade.get_legacy_name("product_id"),
    )
    openupgrade.m2o_to_x2m(
        env.cr,
        env["stock.inventory"],
        "stock_inventory",
        "categ_ids",
        openupgrade.get_legacy_name("category_id"),
    )
    openupgrade.m2o_to_x2m(
        env.cr,
        env["stock.inventory"],
        "stock_inventory",
        "lot_ids",
        openupgrade.get_legacy_name("lot_id"),
    )
def migrate(env, version):
    openupgrade.m2o_to_x2m(env.cr, env['hr.recruitment.stage'],
                           'hr_recruitment_stage', 'job_ids',
                           openupgrade.get_legacy_name('job_id'))
    openupgrade.load_data(env.cr, 'hr_recruitment',
                          'migrations/13.0.1.0/noupdate_changes.xml')
    openupgrade.delete_record_translations(
        env.cr,
        'hr_recruitment',
        [
            'email_template_data_applicant_congratulations',
            'email_template_data_applicant_interest',
            'email_template_data_applicant_refuse',
        ],
    )
def _adjust_reward_specific_products(env):
    """Now the value is `specific_products` instead of `specific_product`, and
    the many2one is now a many2many.
    """
    openupgrade.map_values(
        env.cr,
        openupgrade.get_legacy_name("discount_apply_on"),
        "discount_apply_on",
        [("specific_product", "specific_product")],
        table="sale_coupon_reward",
    )
    openupgrade.m2o_to_x2m(
        env.cr,
        env["sale.coupon.reward"],
        "sale_coupon_reward",
        "discount_specific_product_ids",
        "discount_specific_product_id",
    )
Exemple #15
0
def convert_m2o_to_x2m_fields(env):
    categ_column = openupgrade.get_legacy_name("category_id")
    if openupgrade.column_exists(env.cr, "stock_inventory", categ_column):
        openupgrade.m2o_to_x2m(
            env.cr,
            env["stock.inventory"],
            "stock_inventory",
            "categ_ids",
            categ_column,
        )
    lot_column = openupgrade.get_legacy_name("lot_id")
    if openupgrade.column_exists(env.cr, "stock_inventory", lot_column):
        openupgrade.m2o_to_x2m(
            env.cr,
            env["stock.inventory"],
            "stock_inventory",
            "lot_ids",
            lot_column,
        )
def type_change_account_reconcile_model_taxes(env):
    openupgrade.m2o_to_x2m(env.cr, env['account.reconcile.model'],
                           'account_reconcile_model', 'second_tax_ids',
                           openupgrade.get_legacy_name('second_tax_id'))
    openupgrade.m2o_to_x2m(env.cr, env['account.reconcile.model'],
                           'account_reconcile_model', 'tax_ids',
                           openupgrade.get_legacy_name('tax_id'))
    openupgrade.m2o_to_x2m(env.cr, env['account.reconcile.model.template'],
                           'account_reconcile_model_template',
                           'second_tax_ids',
                           openupgrade.get_legacy_name('second_tax_id'))
    openupgrade.m2o_to_x2m(env.cr, env['account.reconcile.model.template'],
                           'account_reconcile_model_template', 'tax_ids',
                           openupgrade.get_legacy_name('tax_id'))
Exemple #17
0
def convert_many2one_stock_inventory_product_and_location(env):
    openupgrade.m2o_to_x2m(env.cr, env['stock.inventory'], 'stock_inventory',
                           'location_ids',
                           openupgrade.get_legacy_name('location_id'))
    openupgrade.m2o_to_x2m(env.cr, env['stock.inventory'], 'stock_inventory',
                           'product_ids',
                           openupgrade.get_legacy_name('product_id'))
    if openupgrade.column_exists(env.cr, "stock_inventory", "product_domain"):
        # if stock_inventory_preparation_filter is installed
        openupgrade.m2o_to_x2m(
            env.cr,
            env["stock.inventory"],
            "stock_inventory",
            "categ_ids",
            openupgrade.get_legacy_name("category_id"),
        )
        openupgrade.m2o_to_x2m(
            env.cr,
            env["stock.inventory"],
            "stock_inventory",
            "lot_ids",
            openupgrade.get_legacy_name("lot_id"),
        )
def migrate(cr, version):
    map_bank_state(cr)
    map_type_tax_use(cr)
    map_type_tax_use_template(cr)
    map_journal_state(cr)
    account_templates(cr)
    parent_id_to_m2m(cr)
    cashbox(cr)
    account_properties(cr)

    # If the close_method is 'none', then set to 'False', otherwise set to
    # 'True'
    cr.execute("""
    UPDATE account_account_type SET include_initial_balance =  CASE
    WHEN %(openupgrade)s = 'none' THEN False
    ELSE True
    END
    """ % {'openupgrade': openupgrade.get_legacy_name('close_method')})

    # Set bank_statements_source to 'manual'
    cr.execute("""
    UPDATE account_journal SET bank_statements_source = 'manual'
    """)

    # Value 'percentage_of_total' => 'percentage'
    cr.execute("""
    UPDATE account_operation_template SET amount_type = 'percentage'
    WHERE amount_type = 'percentage_of_total'
    """)

    # Set up anglosaxon accounting
    cr.execute(
        "UPDATE res_company SET anglo_saxon_accounting = %s",
        (openupgrade.is_module_installed(cr, 'account_anglo_saxon'), ),
    )

    # deprecate accounts where active is False
    cr.execute("""
    UPDATE account_account SET deprecated = True WHERE active = False
    """)

    # Set display_on_footer to False
    cr.execute("""
    UPDATE account_journal SET display_on_footer = False
    """)

    # Logic to move from child_ids to children_tax_ids (o2m => m2m)
    cr.execute("""
    INSERT INTO account_tax_filiation_rel (parent_tax, child_tax)
    SELECT parent_id, id from account_tax WHERE parent_id IS NOT NULL
    """)

    # Get parent_id and insert it into children_tax_ids (m2o => m2m)
    cr.execute("""
    INSERT INTO account_tax_template_filiation_rel (parent_tax, child_tax)
    SELECT parent_id, id from account_tax_template WHERE parent_id IS NOT NULL
    """)

    # In v8, if child_depend == True, then in v9, set amount_type='group'
    cr.execute("""
    UPDATE account_tax SET amount_type = 'group'
    WHERE child_depend IS True
    """)
    cr.execute("""
    UPDATE account_tax_template SET amount_type = 'group'
    WHERE child_depend IS True
    """)

    registry = RegistryManager.get(cr.dbname)
    openupgrade.m2o_to_x2m(
        cr, registry['account.bank.statement.line'],
        'account_bank_statement_line',
        'journal_entry_ids',
        openupgrade.get_legacy_name('journal_entry_id'),
    )

    parent_id_to_tag(cr, 'account.tax')
    parent_id_to_tag(cr, 'account.account', recursive=True)
    account_internal_type(cr)
def migrate(env, version):
    cr = env.cr
    map_bank_state(cr)
    map_type_tax_use(cr)
    map_type_tax_use_template(cr)
    map_journal_state(cr)
    openupgrade_90.replace_account_types(env, account_type_map)
    account_templates(env)
    parent_id_to_m2m(cr)
    cashbox(cr)
    account_properties(cr)
    # If the close_method is 'none', then set to 'False', otherwise set to
    # 'True'
    cr.execute("""
    UPDATE account_account_type SET include_initial_balance =  CASE
    WHEN %(openupgrade)s = 'none' THEN False
    ELSE True
    END
    """ % {'openupgrade': openupgrade.get_legacy_name('close_method')})

    # Set bank_statements_source to 'manual'
    cr.execute("""
    UPDATE account_journal SET bank_statements_source = 'manual'
    """)

    # Value 'percentage_of_total' => 'percentage'
    cr.execute("""
    UPDATE account_operation_template SET amount_type = 'percentage'
    WHERE amount_type = 'percentage_of_total'
    """)

    # Set up anglosaxon accounting
    cr.execute(
        "UPDATE res_company SET anglo_saxon_accounting = %s",
        (openupgrade.is_module_installed(cr, 'account_anglo_saxon'), ),
    )

    # deprecate accounts where active is False
    cr.execute("""
    UPDATE account_account SET deprecated = True WHERE active = False
    """)

    # Set display_on_footer to False
    cr.execute("""
    UPDATE account_journal SET display_on_footer = False
    """)

    # Logic to move from child_ids to children_tax_ids (o2m => m2m)
    cr.execute("""
    INSERT INTO account_tax_filiation_rel (parent_tax, child_tax)
    SELECT parent_id, id from account_tax WHERE parent_id IS NOT NULL
    """)

    # Get parent_id and insert it into children_tax_ids (m2o => m2m)
    cr.execute("""
    INSERT INTO account_tax_template_filiation_rel (parent_tax, child_tax)
    SELECT parent_id, id from account_tax_template WHERE parent_id IS NOT NULL
    """)

    # In v8, if child_depend == True, then in v9, set amount_type='group'
    cr.execute("""
    UPDATE account_tax SET amount_type = 'group'
    WHERE child_depend IS True
    """)
    cr.execute("""
    UPDATE account_tax_template SET amount_type = 'group'
    WHERE child_depend IS True
    """)

    # In v9, percentages are expressed as hundred-based percentage,
    # not one-based percentage
    cr.execute('UPDATE account_tax set amount=amount*100 '
               "WHERE amount_type='percent'")

    registry = RegistryManager.get(cr.dbname)
    openupgrade.m2o_to_x2m(
        cr,
        registry['account.bank.statement.line'],
        'account_bank_statement_line',
        'journal_entry_ids',
        openupgrade.get_legacy_name('journal_entry_id'),
    )

    parent_id_to_tag(env, 'account.tax')
    parent_id_to_tag(env, 'account.account', recursive=True)
    move_view_accounts(env)
    account_internal_type(env)
    map_account_tax_type(cr)
    map_account_tax_template_type(cr)
    migrate_account_sequence_fiscalyear(cr)
    migrate_account_auto_fy_sequence(env)
    fill_move_taxes(env)
    fill_blacklisted_fields(cr)
    reset_blacklist_field_recomputation()
    fill_move_line_invoice(cr)
    merge_invoice_journals(env)
    update_account_invoice_date(cr)
    update_move_date(cr)
    fill_bank_accounts(cr)
    openupgrade.load_data(
        cr,
        'account',
        'migrations/9.0.1.1/noupdate_changes.xml',
    )
def _field_type_change(env):
    openupgrade.m2o_to_x2m(
        env.cr,
        env['iap.account'], 'iap_account',
        'company_ids', openupgrade.get_legacy_name('company_id')
    )
def convert_many2one_field(env):
    openupgrade.m2o_to_x2m(env.cr, env['stock.move.line'], 'stock_move_line',
                           'lot_produced_ids',
                           openupgrade.get_legacy_name('lot_produced_id'))
Exemple #22
0
def migrate(env, version):
    openupgrade.m2o_to_x2m(env.cr, env['stock.move'], 'stock_move',
                           'invoice_line_ids', 'invoice_line_id')