Example #1
0
def migrate(env, version):
    cr = env.cr
    openupgrade.rename_fields(env, field_renames)
    openupgrade.rename_columns(cr, column_renames)
    openupgrade.rename_tables(cr, table_renames)
Example #2
0
def migrate(env, version):
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_xmlids(env.cr, _xmlid_renames)
    _recover_v8_expense_sheet_draft_state(env)
    openupgrade.set_xml_ids_noupdate_value(
        env, 'hr_expense', ['hr_expense_template_refuse_reason'], True)
Example #3
0
def migrate(env, version):
    openupgrade.copy_columns(env.cr, column_copies)
    openupgrade.rename_columns(env.cr, _column_renames)
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_xmlids(env.cr, _xml_ids_renames)
    identify_act_window_views(env)
Example #4
0
def migrate(env, version):
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_xmlids(env.cr, _xmlid_renames)
Example #5
0
def migrate(env, version):
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_xmlids(env.cr, _xmlid_renames)
    move_lunch_order_line_to_lunch_order(env)
Example #6
0
def migrate(env, version):
    if openupgrade.table_exists(env.cr,
                                "l10n_br_fiscal_document_invalidate_number"):
        openupgrade.rename_models(env.cr, _model_renames)
        openupgrade.rename_tables(env.cr, _table_renames)
        openupgrade.rename_fields(env, _field_renames)
Example #7
0
def migrate(env, version):
    openupgrade.copy_columns(env.cr, column_copies)
    openupgrade.rename_fields(env, _field_renames)
Example #8
0
def migrate(env, version):
    if not version:
        return

    # Muskathlon registration will become event.registration object:
    # Prepare required columns
    if not openupgrade.column_exists(env.cr, 'event_registration', 'lead_id'):
        env.cr.execute("""
            ALTER TABLE event_registration ADD COLUMN lead_id integer;
            ALTER TABLE event_registration
                ADD COLUMN sport_discipline_id integer;
            ALTER TABLE event_registration
                ADD COLUMN sport_level character varying;
            ALTER TABLE event_registration
                ADD COLUMN sport_level_description text;
            ALTER TABLE event_registration ADD COLUMN amount_objective integer;
            ALTER TABLE event_registration
                ADD COLUMN website_published boolean;
            ALTER TABLE event_registration ADD COLUMN reg_id character varying;
            ALTER TABLE event_registration ADD COLUMN backup_id integer;
        """)
    # Insert data for events with registrations open
    events = env['crm.event.compassion'].search([
        ('odoo_event_id', '!=', False),
    ])
    env.cr.execute(
        """INSERT INTO event_registration(create_date,write_uid,
partner_id,create_uid,event_id,company_id,state,email,phone,write_date,origin,
name,date_open,lead_id,sport_discipline_id,sport_level,sport_level_description,
amount_objective,website_published,reg_id,backup_id)

SELECT now(),1,r.partner_id,1,odoo_event_id,1,'draft',p.email,p.phone,now(),
    'Registration automatically migrated',p.name,r.create_date,r.lead_id,
    sport_discipline_id,sport_level,sport_level_description,r.amount_objective,
    r.website_published,reg_id,r.id
    FROM muskathlon_registration r
    JOIN crm_event_compassion e ON r.event_id = e.id
    JOIN res_partner p ON r.partner_id = p.id
    WHERE event_id = ANY(%s)""", [events.ids]
    )
    # Update relations to registration
    table_names = ['account_invoice_line', 'recurring_contract',
                   'payment_transaction']
    env.cr.execute("""
        ALTER TABLE payment_transaction
        RENAME COLUMN registration_id TO muskathlon_registration_id;
        ALTER table payment_transaction
        DROP CONSTRAINT IF EXISTS payment_transaction_registration_id_fkey;
    """)
    for table in table_names:
        env.cr.execute("""
            ALTER table %s
            DROP CONSTRAINT IF EXISTS %s_muskathlon_registration_id_fkey;
        """ % (table, table))
        env.cr.execute("""
            UPDATE %s
            SET muskathlon_registration_id = (
                SELECT id FROM event_registration
                WHERE backup_id = muskathlon_registration_id
            );
        """ % table)
    env.cr.execute("""
        ALTER TABLE payment_transaction
        RENAME COLUMN muskathlon_registration_id TO registration_id;
    """)

    openupgrade.rename_fields(env, [
        ('account.invoice.line', 'account_invoice_line',
         'muskathlon_registration_id', 'registration_id'),
        ('recurring.contract', 'recurring_contract',
         'muskathlon_registration_id', 'registration_id'),
        ('crm.event.compassion', 'crm_event_compassion',
         'muskathlon_registration_ids', 'registration_ids'),
        ('res.partner', 'res_partner',
         'muskathlon_registration_ids', 'registration_ids'),
    ])
Example #9
0
def migrate(env, version):
    cr = env.cr
    # Remove NOT NULL constraint on these obsolete required fields
    openupgrade.logged_query(
        cr, """
        ALTER TABLE product_price_history
        ALTER COLUMN product_template_id DROP NOT NULL
        """)
    # Remove NOT NULL constraint on these obsolete required fields
    openupgrade.logged_query(
        cr, """
        ALTER TABLE product_packaging ALTER COLUMN rows DROP NOT NULL
        """)

    # Remove NOT NULL constraint on these obsolete required fields
    openupgrade.logged_query(
        cr, """
        ALTER TABLE product_packaging ALTER COLUMN ul DROP NOT NULL
        """)

    # Remove NOT NULL constraint on these obsolete required fields
    openupgrade.logged_query(
        cr, """
        ALTER TABLE product_pricelist ALTER COLUMN type DROP NOT NULL
        """)

    # Remove NOT NULL constraint on these obsolete required fields
    openupgrade.logged_query(
        cr, """
        ALTER TABLE product_pricelist_item
        ALTER COLUMN price_version_id DROP NOT NULL
        """)

    openupgrade.rename_columns(cr, column_renames)
    openupgrade.rename_fields(env, field_renames)
    openupgrade.copy_columns(cr, column_copies)

    # Add default value when it is null, as Product name / Package Logistic
    # Unit name
    openupgrade.logged_query(
        cr, """
        WITH q as (
        SELECT pp.id, pt.name as product_name, pu.name as ul_name
        FROM product_packaging as pp
        INNER JOIN product_template as pt
        ON pp.product_tmpl_id = pt.id
        INNER JOIN product_ul as pu
        ON pu.id = pp.ul)
        UPDATE product_packaging as pp
        SET name = q.product_name || '/' || q.ul_name
        FROM q
        WHERE pp.name IS NULL
        AND pp.id = q.id
        """)

    # Install module 'product_uos' if field 'uos_id' has a
    # value in the product.template.
    openupgrade.logged_query(
        cr, """
        UPDATE ir_module_module
        SET state = 'to install'
        FROM (
            SELECT True as to_install
            FROM product_template as pt
            WHERE uos_id is not NULL
            AND uos_id <> uom_id
            LIMIT 1
        ) AS q
        WHERE name = 'product_uos'
        and q.to_install = True
        """)

    cr.execute("update product_template set state=NULL where state=''")

    map_product_template_type(cr)

    # disable purchase price lists
    cr.execute(
        "update product_pricelist set active=False where type='purchase'")
Example #10
0
def rename_old_italian_module(cr):
    """
    Move data and fields
    from italian module `l10n_it_dichiarazione_intento`
    to this module.
    """
    old_module_name = "l10n_it_dichiarazione_intento"

    if not openupgrade.is_module_installed(cr, old_module_name):
        return

    new_module_name = "l10n_it_declaration_of_intent"
    env = api.Environment(cr, SUPERUSER_ID, {})

    old_sequence = env["ir.model.data"].get_object(
        old_module_name, "dichiarazione_intento_seq")
    old_sequence.code = "declaration_of_intent"

    renamed_fields = [
        (
            "res.company",
            "res_company",
            "dichiarazione_yearly_limit_ids",
            "declaration_yearly_limit_ids",
        ),
        (
            "dichiarazione.intento.yearly.limit",
            "dichiarazione_intento_yearly_limit",
            "dichiarazione_id",
            "declaration_id",
        ),
        (
            "dichiarazione.intento.line",
            "dichiarazione_intento_line",
            "dichiarazione_id",
            "declaration_id",
        ),
        (
            "account.fiscal.position",
            "account_fiscal_position",
            "valid_for_dichiarazione_intento",
            "valid_for_declaration_of_intent",
        ),
        (
            "account.move.line",
            "account_move_line",
            "force_dichiarazione_intento_id",
            "force_declaration_of_intent_id",
        ),
        (
            "account.move",
            "account_move",
            "dichiarazione_intento_ids",
            "declaration_of_intent_ids",
        ),
    ]
    openupgrade.rename_fields(
        env,
        renamed_fields,
    )

    renamed_models = [
        (
            "dichiarazione.intento.yearly.limit",
            "l10n_it_declaration_of_intent.yearly_limit",
        ),
        ("dichiarazione.intento", "l10n_it_declaration_of_intent.declaration"),
        (
            "dichiarazione.intento.line",
            "l10n_it_declaration_of_intent.declaration_line",
        ),
    ]
    openupgrade.rename_models(
        cr,
        renamed_models,
    )
    renamed_tables = [(
        old_model.replace(".", "_"),
        new_model.replace(".", "_"),
    ) for old_model, new_model in renamed_models]
    openupgrade.rename_tables(
        cr,
        renamed_tables,
    )

    renamed_xmlids = [
        ("access_dichiarazione_intento", "access_declaration_of_intent"),
        ("access_dichiarazione_intento_base",
         "access_declaration_of_intent_base"),
        ("access_dichiarazione_intento_line",
         "access_declaration_of_intent_line"),
        (
            "access_dichiarazione_intento_yearly_limit",
            "access_declaration_of_intent_yearly_limit",
        ),
        ("dichiarazione_intento_seq", "declaration_of_intent_seq"),
        ("dichiarazione_intento_invoice_form",
         "declaration_of_intent_invoice_form"),
        (
            "dichiarazione_intento_invoice_line_form",
            "declaration_of_intent_invoice_line_form",
        ),
        (
            "dichiarazione_intento_account_position_form",
            "declaration_of_intent_account_position_form",
        ),
        (
            "dichiarazione_intento_view_company_form",
            "declaration_of_intent_view_company_form",
        ),
        ("dichiarazione_intento_form", "declaration_of_intent_form"),
        ("dichiarazione_intento_search", "declaration_of_intent_search"),
        ("dichiarazione_intento_tree", "declaration_of_intent_tree"),
        ("dichiarazione_intento_action", "declaration_of_intent_action"),
        ("dichiarazione_intento_menu", "declaration_of_intent_menu"),
    ]
    renamed_xmlids = [(".".join([old_module_name, old_xmlid]),
                       ".".join([new_module_name, new_xmlid]))
                      for (old_xmlid, new_xmlid) in renamed_xmlids]
    openupgrade.rename_xmlids(
        cr,
        renamed_xmlids,
    )

    renamed_modules = [
        (old_module_name, new_module_name),
    ]
    openupgrade.update_module_names(
        cr,
        renamed_modules,
        merge_modules=True,
    )
Example #11
0
def migrate(env, version):
    cr = env.cr
    openupgrade.copy_columns(cr, column_spec)
    openupgrade.rename_fields(env, field_renames)
Example #12
0
def migrate(env, version):
    cr = env.cr
    openupgrade.rename_tables(cr, _table_renames)
    openupgrade.rename_models(cr, _model_renames)
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_xmlids(cr, _xmlid_renames)
Example #13
0
def migrate(env, version):
    if not version:
        return

    ## rename field
    openupgrade.rename_fields(env, [
        ('lighting.product', 'lighting_product',
         'auxiliary_equipment_model_id', 'auxiliary_equipment_brand_id'),
    ])

    ### rename model
    openupgrade.rename_models(env.cr, [
        ('lighting.product.auxiliaryequipmentmodel',
         'lighting.product.auxiliaryequipmentbrand'),
    ])

    ### rename external ids
    openupgrade.rename_xmlids(env.cr, [
        ('lighting.product_auxiliaryequipmentmodel_elt',
         'lighting.product_auxiliaryequipmentbrand_elt'),
        ('lighting.product_auxiliaryequipmentmodel_meanwell',
         'lighting.product_auxiliaryequipmentbrand_meanwell'),
        ('lighting.product_auxiliaryequipmentmodel_tci',
         'lighting.product_auxiliaryequipmentbrand_tci'),
        ('lighting.product_auxiliaryequipmentmodel_tecnotrafo',
         'lighting.product_auxiliaryequipmentbrand_tecnotrafo'),
        ('lighting.product_auxiliaryequipmentmodel_tridonic',
         'lighting.product_auxiliaryequipmentbrand_tridonic'),
    ])

    ### rename DB
    ## lighting_product_auxiliaryequipmentmodel
    # rename table and sequence
    openupgrade.rename_tables(env.cr,
                              [('lighting_product_auxiliaryequipmentmodel',
                                'lighting_product_auxiliaryequipmentbrand')])

    # rename comments
    env.cr.execute("COMMENT ON TABLE lighting_product_auxiliaryequipmentbrand "
                   "IS 'lighting.product.auxiliaryequipmentbrand'")

    env.cr.execute(
        "COMMENT ON COLUMN lighting_product_auxiliaryequipmentbrand.name "
        "IS 'Auxiliary equipment brand'")

    # rename uniq keys
    env.cr.execute(
        "ALTER TABLE lighting_product_auxiliaryequipmentbrand "
        "RENAME CONSTRAINT lighting_product_auxiliaryequipmentmodel_name_uniq "
        "TO lighting_product_auxiliaryequipmentbrand_name_uniq")

    # rename pkeys
    env.cr.execute(
        "ALTER TABLE lighting_product_auxiliaryequipmentbrand "
        "RENAME CONSTRAINT lighting_product_auxiliaryequipmentmodel_pkey "
        "TO lighting_product_auxiliaryequipmentbrand_pkey")

    # rename fkeys
    env.cr.execute(
        "ALTER TABLE lighting_product_auxiliaryequipmentbrand "
        "RENAME CONSTRAINT lighting_product_auxiliaryequipmentmodel_create_uid_fkey "
        "TO lighting_product_auxiliaryequipmentbrand_create_uid_fkey")

    env.cr.execute(
        "ALTER TABLE lighting_product_auxiliaryequipmentbrand "
        "RENAME CONSTRAINT lighting_product_auxiliaryequipmentmodel_write_uid_fkey "
        "TO lighting_product_auxiliaryequipmentbrand_write_uid_fkey")

    ## lighting_product
    # rename comments
    env.cr.execute(
        "COMMENT ON COLUMN lighting_product.auxiliary_equipment_brand_id "
        "IS 'Auxiliary equipment brand'")

    # rename fkeys
    env.cr.execute(
        "ALTER TABLE lighting_product "
        "RENAME CONSTRAINT lighting_product_auxiliary_equipment_model_id_fkey "
        "TO lighting_product_auxiliary_equipment_brand_id_fkey")
Example #14
0
def migrate(env, version):
    openupgrade.rename_columns(env.cr, _column_renames)
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_models(env.cr, _model_renames)
    openupgrade.rename_tables(env.cr, _table_renames)
    openupgrade.rename_xmlids(env.cr, xmlid_renames)
Example #15
0
def rename_to_refund_so(env):
    """Rename `to_refund_so` if exists and update field definition."""
    if openupgrade.column_exists(env.cr, 'stock_move', 'to_refund_so'):
        openupgrade.rename_fields(
            env, [('stock.move', 'stock_move', 'to_refund_so', 'to_refund')],
        )
Example #16
0
def migrate(env, version):
    rename_hr_timesheet_sheet(env.cr)
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.copy_columns(env.cr, _column_copies)
    openupgrade.rename_xmlids(env.cr, _xmlid_renames)
Example #17
0
def migrate(env, version):
    openupgrade.rename_fields(env, _field_renames)
    invert_website_sequence(env)
Example #18
0
def migrate(env, version):
    openupgrade.rename_fields(env, field_renames)
Example #19
0
def migrate(env, version):
    if openupgrade.column_exists(env.cr, 'hr_employee', 'vehicle_distance'):
        openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_xmlids(env.cr, xmlid_renames)